From fe3c0167ba16f83d2146594d2ef7edea5e07a899 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Wed, 24 Jul 2019 08:14:18 +0300 Subject: [PATCH 1/2] Changed: Disable r2_islands_textures, ai_build_wmap, build_world_packed_col because no server code in yubo/atys branch. --HG-- branch : atys --- code/ryzom/server/CMakeLists.txt | 2 +- code/ryzom/tools/client/CMakeLists.txt | 3 ++- code/ryzom/tools/server/CMakeLists.txt | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/ryzom/server/CMakeLists.txt b/code/ryzom/server/CMakeLists.txt index 4b7537b55..0d2f4ffc4 100644 --- a/code/ryzom/server/CMakeLists.txt +++ b/code/ryzom/server/CMakeLists.txt @@ -1 +1 @@ -ADD_SUBDIRECTORY(src) +#ADD_SUBDIRECTORY(src) diff --git a/code/ryzom/tools/client/CMakeLists.txt b/code/ryzom/tools/client/CMakeLists.txt index d4f136b3c..2a9cfc59e 100644 --- a/code/ryzom/tools/client/CMakeLists.txt +++ b/code/ryzom/tools/client/CMakeLists.txt @@ -15,5 +15,6 @@ IF(WITH_QT5 AND WITH_RYZOM_INSTALLER) ENDIF() IF(WITH_RYZOM_TOOLS AND MYSQL_FOUND) - ADD_SUBDIRECTORY(r2_islands_textures) + # requires which is missing from yubo/atys branch + #ADD_SUBDIRECTORY(r2_islands_textures) ENDIF() diff --git a/code/ryzom/tools/server/CMakeLists.txt b/code/ryzom/tools/server/CMakeLists.txt index 1e8a6edb9..310fd7583 100644 --- a/code/ryzom/tools/server/CMakeLists.txt +++ b/code/ryzom/tools/server/CMakeLists.txt @@ -1,10 +1,12 @@ IF(WITH_RYZOM_TOOLS) IF(WITH_LIGO) - ADD_SUBDIRECTORY(ai_build_wmap) + # Disabled because no server code in atys/yubo branch + #ADD_SUBDIRECTORY(ai_build_wmap) ENDIF() IF(WITH_3D) - ADD_SUBDIRECTORY(build_world_packed_col) + # Disabled because no server code in atys/yubo branch + #ADD_SUBDIRECTORY(build_world_packed_col) ENDIF() ENDIF() From a4d2f80579d3ae5e9d2e2a5745a702895bb645b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Gon=C3=A7alves?= Date: Fri, 13 Sep 2019 01:17:16 +0200 Subject: [PATCH 2/2] Added: A way to run lua per ZONE wiht ZONE_ID.lua files (usefull to spawn shapes) --HG-- branch : ark --- code/nel/src/pacs/move_container.cpp | 3 +- code/ryzom/client/src/continent.cpp | 41 ++++++++++- code/ryzom/client/src/entities.cpp | 69 ++++++++++++------- code/ryzom/client/src/entities.h | 10 ++- .../src/interface_v3/action_handler_game.cpp | 2 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 13 +++- 6 files changed, 106 insertions(+), 32 deletions(-) diff --git a/code/nel/src/pacs/move_container.cpp b/code/nel/src/pacs/move_container.cpp index c302b53ab..b885712d9 100644 --- a/code/nel/src/pacs/move_container.cpp +++ b/code/nel/src/pacs/move_container.cpp @@ -415,7 +415,7 @@ void CMoveContainer::updateCells (CMovePrimitive *primitive, uint8 worldImage) CPrimitiveWorldImage *wI=primitive->getWorldImage (worldImage); #if !FINAL_VERSION - // Check BB width not too large +/* // Check BB width not too large if (wI->getBBXMax() - wI->getBBXMin() > _CellWidth) { 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."); } +*/ #endif // Get coordinate in the cell array diff --git a/code/ryzom/client/src/continent.cpp b/code/ryzom/client/src/continent.cpp index a30604282..51334195b 100644 --- a/code/ryzom/client/src/continent.cpp +++ b/code/ryzom/client/src/continent.cpp @@ -38,6 +38,8 @@ #include "nel/georges/u_form.h" #include "nel/georges/u_form_elm.h" #include "nel/georges/u_form_loader.h" +// Gui +#include "nel/gui/lua_manager.h" // Client #include "global.h" #include "continent.h" @@ -108,7 +110,7 @@ extern UVisualCollisionManager *CollisionManager; extern bool InitCloudScape; extern bool FirstFrame; extern CContinentManager ContinentMngr; - +extern CEntityManager EntitiesMngr; //----------------------------------------------- // CUserLandMark @@ -385,6 +387,23 @@ static uint getNumZones() 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 : // Update global parameters like the texture for the micro veget. @@ -717,6 +736,26 @@ void CContinent::select(const CVectorD &pos, NLMISC::IProgressCallback &progress vector zonesRemoved; 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); + + 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.loadArrayZoneIG(zonesAdded, &igAdded); } diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index 495471da1..ab3de2b99 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -529,7 +529,7 @@ void CEntityManager::reinit() 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; CShapeInstanceReference nullinstref(UInstance(), string(""), string("")); @@ -557,17 +557,42 @@ CShapeInstanceReference CEntityManager::createInstance(const string& shape, cons _ShapeInstances[idx].ContextURL = url; _ShapeInstances[idx].BboxActive = !text.empty() || !url.empty(); _ShapeInstances[idx].Deleted = false; + _ShapeInstances[idx].InIGZone = inIgZone > 0; _LastRemovedInstance = _ShapeInstances[idx].LastDeleted; _ShapeInstances[idx].LastDeleted = -1; + TIGZoneShapes::iterator it = _IgZoneShapes.find(inIgZone); + if (it == _IgZoneShapes.end()) + { + vector shapes; + shapes.push_back(idx); + _IgZoneShapes.insert(make_pair(inIgZone, shapes)); + } + else + { + vector &shapes = (*it).second; + shapes.push_back(idx); + } return _ShapeInstances[idx]; } 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; idx = _ShapeInstances.size(); _ShapeInstances.push_back(instref); + TIGZoneShapes::iterator it = _IgZoneShapes.find(inIgZone); + if (it == _IgZoneShapes.end()) + { + vector shapes; + shapes.push_back(idx); + _IgZoneShapes.insert(make_pair(inIgZone, shapes)); + } + else + { + vector &shapes = (*it).second; + shapes.push_back(idx); + } return instref; } } @@ -583,9 +608,7 @@ bool CEntityManager::deleteInstance(uint32 idx) Scene->deleteInstance(_ShapeInstances[idx].Instance); UMovePrimitive *primitive = _ShapeInstances[idx].Primitive; if (primitive) - { PACS->removePrimitive(primitive); - } if (!_ShapeInstances[idx].Deleted) { @@ -598,6 +621,22 @@ bool CEntityManager::deleteInstance(uint32 idx) return true; } +void CEntityManager::removeInstancesInIgZone(uint16 igZone) +{ + if (!Scene) + return; + + TIGZoneShapes::iterator it = _IgZoneShapes.find(igZone); + if (it != _IgZoneShapes.end()) + { + vector &shapes = (*it).second; + for (uint i = 0; i < shapes.size(); i++) + deleteInstance(shapes[i]); + _IgZoneShapes.erase(it); + } + +} + CVector CEntityManager::getInstancePos(uint32 idx) { if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted) @@ -758,31 +797,15 @@ CVector CEntityManager::getInstanceBBoxMax(uint32 idx) bool CEntityManager::removeInstances() { if (!Scene) return false; - // Remove all instances. + for(uint i=0; i<_ShapeInstances.size(); ++i) { - if (!_ShapeInstances[i].Instance.empty()) - Scene->deleteInstance(_ShapeInstances[i].Instance); - - UMovePrimitive *primitive = _ShapeInstances[i].Primitive; - if (primitive) - { - PACS->removePrimitive(primitive); - } + if (!_ShapeInstances[i].InIGZone) + deleteInstance(i); } - _ShapeInstances.clear(); - _InstancesRemoved = true; - _LastRemovedInstance = -1; return true; } -bool CEntityManager::instancesRemoved() -{ - bool instRemoved = _InstancesRemoved; - _InstancesRemoved = false; - return instRemoved; -} - bool CEntityManager::setupInstance(uint32 idx, const vector &keys, const vector &values) { if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted) diff --git a/code/ryzom/client/src/entities.h b/code/ryzom/client/src/entities.h index 1151a367d..8372429db 100644 --- a/code/ryzom/client/src/entities.h +++ b/code/ryzom/client/src/entities.h @@ -95,7 +95,7 @@ public: class CShapeInstanceReference { 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; ContextText = text; @@ -103,6 +103,7 @@ public: BboxActive = bbox_active; Deleted = false; LastDeleted = -1; + InIGZone = in_ig_zone; Primitive = NULL; PrimSize = CVector(1.f, 1.f, 1.f); PrimHeight = 1.f; @@ -118,6 +119,7 @@ public: string ContextURL; bool BboxActive; bool Deleted; + bool InIGZone; sint32 LastDeleted; }; @@ -143,6 +145,8 @@ private: std::vector _VisibleEntities; /// Shapes Instances caches + typedef std::map> TIGZoneShapes; + TIGZoneShapes _IgZoneShapes; std::vector _ShapeInstances; sint32 _LastRemovedInstance; bool _InstancesRemoved; @@ -226,9 +230,10 @@ public: 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 removeInstances(); + void removeInstancesInIgZone(uint16 igZone); CVector getInstancePos(uint32 idx); bool setInstancePos(uint32 idx, CVector pos); CVector getInstanceRot(uint32 idx); @@ -239,7 +244,6 @@ public: CVector getInstanceBBoxMin(uint32 idx); CVector getInstanceBBoxMax(uint32 idx); bool setInstanceRot(uint32 idx, CVector pos); - bool instancesRemoved(); bool setupInstance(uint32 idx, const std::vector &keys, const std::vector &values); CShapeInstanceReference getShapeInstanceUnderPos(float x, float y, sint32 &idx); diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 9ccdf1b11..989e0e11f 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -2555,7 +2555,7 @@ class CAHAddShape : public IActionHandler } 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; if(!instance.empty()) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 061644335..f8d9b85e5 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -2070,14 +2070,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) { const char* funcName = "addShape"; CLuaIHM::checkArgMin(ls, funcName, 1); - CLuaIHM::checkArgMax(ls, funcName, 13); + CLuaIHM::checkArgMax(ls, funcName, 14); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); sint32 idx = -1; @@ -2097,6 +2097,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) bool highlight = false; bool transparency = false; bool collision = true; + bool inIgZone = false; if (ls.getTop() >= 2) { @@ -2187,7 +2188,13 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) 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; if(!instance.empty())