Merge ark into yubo

--HG--
branch : yubo
hg/yubo
Nuno Gonçalves 5 years ago
commit 683af88cb9

@ -1,4 +1,3 @@
950d650ca92e6041611258d7e5131ccf661e4ec2 compatibility-merge
4eddbaff0c5e5d685db96ee3e8427aa0fd96ac83 ryzomcore/v0.8.0 4eddbaff0c5e5d685db96ee3e8427aa0fd96ac83 ryzomcore/v0.8.0
00d9b6e29e95f56785fbf85abe60afd34674f402 ryzomcore/v0.9.0 00d9b6e29e95f56785fbf85abe60afd34674f402 ryzomcore/v0.9.0
79776c337176dd5b02e1a74fe5dfb703b91747aa ryzomcore/v0.9.1 79776c337176dd5b02e1a74fe5dfb703b91747aa ryzomcore/v0.9.1
@ -17,11 +16,13 @@ d4060f217f4f834cc62a33f2f1ccdf3c28298066 ryzom-patch-3.1.0-hotfix
4036ecf59e83960f03acebc2089eb2ff5eeaed0a ryzom-patch-3.2.0 4036ecf59e83960f03acebc2089eb2ff5eeaed0a ryzom-patch-3.2.0
18403bb9485da3d9742c6f007a16d5619ebfb196 ryzom-patch-3.2.1 18403bb9485da3d9742c6f007a16d5619ebfb196 ryzom-patch-3.2.1
822ff8f8917ad66e09e2c21c983282f6f693b9f6 ryzom-patch-3.3.0 822ff8f8917ad66e09e2c21c983282f6f693b9f6 ryzom-patch-3.3.0
00dde390a394fce9da06c2f3264140282158d39f 3.3.0 00dde390a394fce9da06c2f3264140282158d39f ryzom-patch-3.3.0
0000000000000000000000000000000000000000 3.3.0 dcd4c4d161ef775136e18c7e8f5072b75dede27e ryzom-patch-3.3.1
fc4be8ebec5ca754ef4453bc6a9faef90837c674 ryzom-patch-3.4.0 fc4be8ebec5ca754ef4453bc6a9faef90837c674 ryzom-patch-3.4.0
70eba02e8eab6920586dbabf74e9e8180c729980 ryzom-patch-3.4.0 Steam Fix 70eba02e8eab6920586dbabf74e9e8180c729980 ryzom-patch-3.4.0 Steam Fix
3941482843f9cd130cfc16634efc08d34a98ed35 ryzom-patch-3.4.0 Atysmas 3941482843f9cd130cfc16634efc08d34a98ed35 ryzom-patch-3.4.0 Atysmas
ecae9feb4cceb78103e5d7236caccaf450796cdb ryzom-patch-3.5.0 ecae9feb4cceb78103e5d7236caccaf450796cdb ryzom-patch-3.5.0
95783afa226f241062134eb62f4323295d29ac84 ryzom-patch-3.5.0.9637 95783afa226f241062134eb62f4323295d29ac84 ryzom-patch-3.5.0.9637
2102fb276eb69d49ed4923042215312a63c47c08 Live-746 2102fb276eb69d49ed4923042215312a63c47c08 Live-746
8eb94c3549be898fdc4a7c6d791d2477bdc11a18 ryzomcore/v1.0.1
3e92c7104c20d6bc6c2147b4b5fc289e8621d322 ryzomcore/v1.0.0

@ -415,7 +415,7 @@ void CMoveContainer::updateCells (CMovePrimitive *primitive, uint8 worldImage)
CPrimitiveWorldImage *wI=primitive->getWorldImage (worldImage); CPrimitiveWorldImage *wI=primitive->getWorldImage (worldImage);
#if !FINAL_VERSION #if !FINAL_VERSION
// Check BB width not too large /* // Check BB width not too large
if (wI->getBBXMax() - wI->getBBXMin() > _CellWidth) if (wI->getBBXMax() - wI->getBBXMin() > _CellWidth)
{ {
nlwarning ("Primitives have moved more than a cell."); nlwarning ("Primitives have moved more than a cell.");
@ -426,6 +426,7 @@ void CMoveContainer::updateCells (CMovePrimitive *primitive, uint8 worldImage)
{ {
nlwarning ("Primitives have moved more than a cell."); nlwarning ("Primitives have moved more than a cell.");
} }
*/
#endif #endif
// Get coordinate in the cell array // Get coordinate in the cell array

@ -38,6 +38,8 @@
#include "nel/georges/u_form.h" #include "nel/georges/u_form.h"
#include "nel/georges/u_form_elm.h" #include "nel/georges/u_form_elm.h"
#include "nel/georges/u_form_loader.h" #include "nel/georges/u_form_loader.h"
// Gui
#include "nel/gui/lua_manager.h"
// Client // Client
#include "global.h" #include "global.h"
#include "continent.h" #include "continent.h"
@ -108,7 +110,7 @@ extern UVisualCollisionManager *CollisionManager;
extern bool InitCloudScape; extern bool InitCloudScape;
extern bool FirstFrame; extern bool FirstFrame;
extern CContinentManager ContinentMngr; extern CContinentManager ContinentMngr;
extern CEntityManager EntitiesMngr;
//----------------------------------------------- //-----------------------------------------------
// CUserLandMark // CUserLandMark
@ -385,6 +387,23 @@ static uint getNumZones()
return (uint)zoneLoaded.size(); return (uint)zoneLoaded.size();
} }
static uint16 getZoneIdFromName(const string &zoneName)
{
uint16 zoneId = 0;
CVector2f pos;
if (getPosFromZoneName(zoneName, pos))
{
uint x = (uint)pos.x / 160;
uint y = -(uint)pos.y / 160;
zoneId = (x&255) + (y<<8);
}
else
{
nlinfo("no zone...");
}
return zoneId;
}
//----------------------------------------------- //-----------------------------------------------
// select : // select :
// Update global parameters like the texture for the micro veget. // Update global parameters like the texture for the micro veget.
@ -717,6 +736,26 @@ void CContinent::select(const CVectorD &pos, NLMISC::IProgressCallback &progress
vector<string> zonesRemoved; vector<string> zonesRemoved;
completeIsland = R2::CScenarioEntryPoints::getInstance().getCompleteIslandFromCoords(CVector2f((float) UserEntity->pos().x, (float) UserEntity->pos().y)); completeIsland = R2::CScenarioEntryPoints::getInstance().getCompleteIslandFromCoords(CVector2f((float) UserEntity->pos().x, (float) UserEntity->pos().y));
Landscape->refreshAllZonesAround(pos, ClientCfg.Vision + ExtraZoneLoadingVision, zonesAdded, zonesRemoved, progress, completeIsland ? &(completeIsland->ZoneIDs) : NULL); Landscape->refreshAllZonesAround(pos, ClientCfg.Vision + ExtraZoneLoadingVision, zonesAdded, zonesRemoved, progress, completeIsland ? &(completeIsland->ZoneIDs) : NULL);
for (uint i = 0; i < zonesRemoved.size(); i++)
EntitiesMngr.removeInstancesInIgZone(getZoneIdFromName(zonesRemoved[i]));
for (uint i = 0; i < zonesAdded.size(); i++)
{
CSString luaScript;
string luaScriptName = CPath::lookup(zonesAdded[i]+".lua", false);
if (!luaScriptName.empty())
{
luaScript.readFromFile(luaScriptName);
CLuaManager::getInstance().executeLuaScript(luaScript, true);
nlinfo("loading %s", luaScriptName.c_str());
}
else
{
nlinfo("file not found %s", luaScriptName.c_str());
}
}
LandscapeIGManager.unloadArrayZoneIG(zonesRemoved); LandscapeIGManager.unloadArrayZoneIG(zonesRemoved);
LandscapeIGManager.loadArrayZoneIG(zonesAdded, &igAdded); LandscapeIGManager.loadArrayZoneIG(zonesAdded, &igAdded);
} }

@ -529,7 +529,7 @@ void CEntityManager::reinit()
initialize(_NbMaxEntity); initialize(_NbMaxEntity);
} }
CShapeInstanceReference CEntityManager::createInstance(const string& shape, const CVector &pos, const string& text, const string& url, bool haveCollisions, sint32& idx) CShapeInstanceReference CEntityManager::createInstance(const string& shape, const CVector &pos, const string& text, const string& url, bool haveCollisions, uint16 inIgZone, sint32& idx)
{ {
idx = -1; idx = -1;
CShapeInstanceReference nullinstref(UInstance(), string(""), string("")); CShapeInstanceReference nullinstref(UInstance(), string(""), string(""));
@ -557,17 +557,42 @@ CShapeInstanceReference CEntityManager::createInstance(const string& shape, cons
_ShapeInstances[idx].ContextURL = url; _ShapeInstances[idx].ContextURL = url;
_ShapeInstances[idx].BboxActive = !text.empty() || !url.empty(); _ShapeInstances[idx].BboxActive = !text.empty() || !url.empty();
_ShapeInstances[idx].Deleted = false; _ShapeInstances[idx].Deleted = false;
_ShapeInstances[idx].InIGZone = inIgZone > 0;
_LastRemovedInstance = _ShapeInstances[idx].LastDeleted; _LastRemovedInstance = _ShapeInstances[idx].LastDeleted;
_ShapeInstances[idx].LastDeleted = -1; _ShapeInstances[idx].LastDeleted = -1;
TIGZoneShapes::iterator it = _IgZoneShapes.find(inIgZone);
if (it == _IgZoneShapes.end())
{
vector<uint32> shapes;
shapes.push_back(idx);
_IgZoneShapes.insert(make_pair(inIgZone, shapes));
}
else
{
vector<uint32> &shapes = (*it).second;
shapes.push_back(idx);
}
return _ShapeInstances[idx]; return _ShapeInstances[idx];
} }
else else
{ {
CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, !text.empty() || !url.empty()); CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, !text.empty() || !url.empty(), inIgZone > 0);
instref.Primitive = primitive; instref.Primitive = primitive;
idx = _ShapeInstances.size(); idx = _ShapeInstances.size();
_ShapeInstances.push_back(instref); _ShapeInstances.push_back(instref);
TIGZoneShapes::iterator it = _IgZoneShapes.find(inIgZone);
if (it == _IgZoneShapes.end())
{
vector<uint32> shapes;
shapes.push_back(idx);
_IgZoneShapes.insert(make_pair(inIgZone, shapes));
}
else
{
vector<uint32> &shapes = (*it).second;
shapes.push_back(idx);
}
return instref; return instref;
} }
} }
@ -583,9 +608,7 @@ bool CEntityManager::deleteInstance(uint32 idx)
Scene->deleteInstance(_ShapeInstances[idx].Instance); Scene->deleteInstance(_ShapeInstances[idx].Instance);
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive; UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
if (primitive) if (primitive)
{
PACS->removePrimitive(primitive); PACS->removePrimitive(primitive);
}
if (!_ShapeInstances[idx].Deleted) if (!_ShapeInstances[idx].Deleted)
{ {
@ -598,6 +621,22 @@ bool CEntityManager::deleteInstance(uint32 idx)
return true; return true;
} }
void CEntityManager::removeInstancesInIgZone(uint16 igZone)
{
if (!Scene)
return;
TIGZoneShapes::iterator it = _IgZoneShapes.find(igZone);
if (it != _IgZoneShapes.end())
{
vector<uint32> &shapes = (*it).second;
for (uint i = 0; i < shapes.size(); i++)
deleteInstance(shapes[i]);
_IgZoneShapes.erase(it);
}
}
CVector CEntityManager::getInstancePos(uint32 idx) CVector CEntityManager::getInstancePos(uint32 idx)
{ {
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted) if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
@ -758,31 +797,15 @@ CVector CEntityManager::getInstanceBBoxMax(uint32 idx)
bool CEntityManager::removeInstances() bool CEntityManager::removeInstances()
{ {
if (!Scene) return false; if (!Scene) return false;
// Remove all instances.
for(uint i=0; i<_ShapeInstances.size(); ++i) for(uint i=0; i<_ShapeInstances.size(); ++i)
{ {
if (!_ShapeInstances[i].Instance.empty()) if (!_ShapeInstances[i].InIGZone)
Scene->deleteInstance(_ShapeInstances[i].Instance); deleteInstance(i);
UMovePrimitive *primitive = _ShapeInstances[i].Primitive;
if (primitive)
{
PACS->removePrimitive(primitive);
}
} }
_ShapeInstances.clear();
_InstancesRemoved = true;
_LastRemovedInstance = -1;
return true; return true;
} }
bool CEntityManager::instancesRemoved()
{
bool instRemoved = _InstancesRemoved;
_InstancesRemoved = false;
return instRemoved;
}
bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const vector<string> &values) bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const vector<string> &values)
{ {
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted) if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)

@ -95,7 +95,7 @@ public:
class CShapeInstanceReference class CShapeInstanceReference
{ {
public: public:
CShapeInstanceReference (NL3D::UInstance instance, const string &text, const string &url, bool bbox_active=true) CShapeInstanceReference (NL3D::UInstance instance, const string &text, const string &url, bool bbox_active=true, bool in_ig_zone = false)
{ {
Instance = instance; Instance = instance;
ContextText = text; ContextText = text;
@ -103,6 +103,7 @@ public:
BboxActive = bbox_active; BboxActive = bbox_active;
Deleted = false; Deleted = false;
LastDeleted = -1; LastDeleted = -1;
InIGZone = in_ig_zone;
Primitive = NULL; Primitive = NULL;
PrimSize = CVector(1.f, 1.f, 1.f); PrimSize = CVector(1.f, 1.f, 1.f);
PrimHeight = 1.f; PrimHeight = 1.f;
@ -118,6 +119,7 @@ public:
string ContextURL; string ContextURL;
bool BboxActive; bool BboxActive;
bool Deleted; bool Deleted;
bool InIGZone;
sint32 LastDeleted; sint32 LastDeleted;
}; };
@ -143,6 +145,8 @@ private:
std::vector<CEntityReference> _VisibleEntities; std::vector<CEntityReference> _VisibleEntities;
/// Shapes Instances caches /// Shapes Instances caches
typedef std::map<uint16, std::vector<uint32>> TIGZoneShapes;
TIGZoneShapes _IgZoneShapes;
std::vector<CShapeInstanceReference> _ShapeInstances; std::vector<CShapeInstanceReference> _ShapeInstances;
sint32 _LastRemovedInstance; sint32 _LastRemovedInstance;
bool _InstancesRemoved; bool _InstancesRemoved;
@ -226,9 +230,10 @@ public:
void reinit(); void reinit();
CShapeInstanceReference createInstance(const string& shape, const CVector &pos, const string &text, const string &url, bool haveCollisions, sint32 &idx); CShapeInstanceReference createInstance(const string& shape, const CVector &pos, const string &text, const string &url, bool haveCollisions, uint16 inIgZone, sint32 &idx);
bool deleteInstance(uint32 idx); bool deleteInstance(uint32 idx);
bool removeInstances(); bool removeInstances();
void removeInstancesInIgZone(uint16 igZone);
CVector getInstancePos(uint32 idx); CVector getInstancePos(uint32 idx);
bool setInstancePos(uint32 idx, CVector pos); bool setInstancePos(uint32 idx, CVector pos);
CVector getInstanceRot(uint32 idx); CVector getInstanceRot(uint32 idx);
@ -239,7 +244,6 @@ public:
CVector getInstanceBBoxMin(uint32 idx); CVector getInstanceBBoxMin(uint32 idx);
CVector getInstanceBBoxMax(uint32 idx); CVector getInstanceBBoxMax(uint32 idx);
bool setInstanceRot(uint32 idx, CVector pos); bool setInstanceRot(uint32 idx, CVector pos);
bool instancesRemoved();
bool setupInstance(uint32 idx, const std::vector<std::string> &keys, const std::vector<std::string> &values); bool setupInstance(uint32 idx, const std::vector<std::string> &keys, const std::vector<std::string> &values);
CShapeInstanceReference getShapeInstanceUnderPos(float x, float y, sint32 &idx); CShapeInstanceReference getShapeInstanceUnderPos(float x, float y, sint32 &idx);

@ -2594,7 +2594,7 @@ class CAHAddShape : public IActionHandler
} }
sint32 idx; sint32 idx;
CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector((float)x, (float)y, (float)z), c, u, false, idx); CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector((float)x, (float)y, (float)z), c, u, false, 0, idx);
UInstance instance = instref.Instance; UInstance instance = instref.Instance;
if(!instance.empty()) if(!instance.empty())

@ -2071,14 +2071,14 @@ int CLuaIHMRyzom::getIslandId(CLuaState &ls)
// *************************************************************************** // ***************************************************************************
// //
// addShape("shape", .x, .y, .z, "angle", .scale, collision?, "context", "url", highlight?, transparency?, "texture", "skeleton") // addShape("shape", .x, .y, .z, "angle", .scale, collision?, "context", "url", highlight?, transparency?, "texture", "skeleton", "inIgZone?")
// //
//******** //********
int CLuaIHMRyzom::addShape(CLuaState &ls) int CLuaIHMRyzom::addShape(CLuaState &ls)
{ {
const char* funcName = "addShape"; const char* funcName = "addShape";
CLuaIHM::checkArgMin(ls, funcName, 1); CLuaIHM::checkArgMin(ls, funcName, 1);
CLuaIHM::checkArgMax(ls, funcName, 13); CLuaIHM::checkArgMax(ls, funcName, 14);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
sint32 idx = -1; sint32 idx = -1;
@ -2098,6 +2098,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls)
bool highlight = false; bool highlight = false;
bool transparency = false; bool transparency = false;
bool collision = true; bool collision = true;
bool inIgZone = false;
if (ls.getTop() >= 2) if (ls.getTop() >= 2)
{ {
@ -2188,7 +2189,13 @@ int CLuaIHMRyzom::addShape(CLuaState &ls)
skeleton = ls.toString(13); skeleton = ls.toString(13);
} }
CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector(x, y, z), context, url, collision, idx); if (ls.getTop() >= 14)
{
CLuaIHM::checkArgType(ls, funcName, 14, LUA_TBOOLEAN);
inIgZone = ls.toBoolean(14);
}
CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector(x, y, z), context, url, collision, inIgZone, idx);
UInstance instance = instref.Instance; UInstance instance = instref.Instance;
if(!instance.empty()) if(!instance.empty())

Loading…
Cancel
Save