From 56c4674d106ce689945ac5a754027d1704538695 Mon Sep 17 00:00:00 2001 From: "ulukyn@gmail.com" Date: Tue, 10 Jan 2017 12:32:44 +0100 Subject: [PATCH] Fixed: Scenographic Editor crash the client --HG-- branch : compatibility-develop --- code/ryzom/client/src/actions.h | 10 +- code/ryzom/client/src/cursor_functions.cpp | 71 +++++------- code/ryzom/client/src/entities.cpp | 127 ++++++++++++++++++++- code/ryzom/client/src/entities.h | 2 + 4 files changed, 158 insertions(+), 52 deletions(-) diff --git a/code/ryzom/client/src/actions.h b/code/ryzom/client/src/actions.h index b177c1818..51499f43e 100644 --- a/code/ryzom/client/src/actions.h +++ b/code/ryzom/client/src/actions.h @@ -281,16 +281,16 @@ public: // HashMapTraits for NLMISC::TKey struct CTKeyHashMapTraits { - enum { bucket_size = 4, min_buckets = 8, }; - CTKeyHashMapTraits() { } + //enum { bucket_size = 4, min_buckets = 8, }; + //CTKeyHashMapTraits() { } size_t operator() (NLMISC::TKey key) const { - return (size_t)key; + return static_cast(key); } - bool operator() (NLMISC::TKey key1, NLMISC::TKey key2) const + /*bool operator() (NLMISC::TKey key1, NLMISC::TKey key2) const { return key1 < key2; - } + }*/ }; /** diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index 8796d509a..7b581b808 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -60,8 +60,7 @@ CLFECOMMON::TCLEntityId SlotUnderCursor; uint32 MissionId = 0; uint32 MissionRingId = 0; sint32 InstanceId = 0; -UInstance selectedInstance; -const UInstance noSelectedInstance; +sint32 selectedInstance = -1; string selectedInstanceURL; static NLMISC::CRefPtr s_UserCharFade; @@ -129,7 +128,7 @@ void initContextualCursor() ContextCur.add(true, "MISSION", string(""), 0.0f, checkUnderCursor, contextMission); ContextCur.add(true, "WEB PAGE", string(""), 0.0f, checkUnderCursor, contextWebPage); ContextCur.add(true, "WEBIG", string(""), 0.0f, checkUnderCursor, contextWebIG); - ContextCur.add(false, "ARKITECT", string("curs_pick.tga"), 0.0f, checkUnderCursor, contextARKitect); + ContextCur.add(false, "ARKITECT", string("curs_create.tga"), 0.0f, checkUnderCursor, contextARKitect); ContextCur.add(true, "OUTPOST", string(""), 0.0f, checkUnderCursor, contextOutpost); ContextCur.add(true, "RING MISSION", string(""), 0.0f, checkUnderCursor, contextRingMission); ContextCur.add(true, "BUILD_TOTEM", string("uimGcmChooseBuilding"), 0.0f, checkUnderCursor, contextBuildTotem); @@ -346,7 +345,6 @@ void checkUnderCursor() // Entity Under the cursor is the entity selected. else { - // Wait for the target is up to date. Do not display context cursor if the user is mounted. if( (UserEntity->selection() == UserEntity->targetSlot()) && (! UserEntity->isRiding()) ) @@ -536,59 +534,49 @@ void checkUnderCursor() sint32 instance_idx; CShapeInstanceReference instref = EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY, instance_idx); - if (EntitiesMngr.instancesRemoved()) - selectedInstance = noSelectedInstance; - + std::vector keys; + keys.push_back("colorize"); + + if (instance_idx != selectedInstance && selectedInstance != -1) { + std::vector values; + values.push_back("0"); + EntitiesMngr.setupInstance((uint32)selectedInstance, keys, values); + } + UInstance instance = instref.Instance; - if (!instance.empty()) + if (!instance.empty() && !instref.ContextURL.empty()) { - if (instance.getObjectPtr() != selectedInstance.getObjectPtr()) - { - for(uint j=0;j values; + values.push_back("#FF0000FF"); + EntitiesMngr.setupInstance((uint32)instance_idx, keys, values); + selectedInstance = instance_idx; + } + + cursor->setCursor("r2ed_tool_select_move_over.tga"); InstanceId = instance_idx; - if(ContextCur.context("ARKITECT", 0.f, ucstring())) + if (ContextCur.context("ARKITECT", 0.f, ucstring("Edit"))) return; } else { + cursor->setCursor("curs_pick.tga"); ucstring contextText; contextText.fromUtf8(instref.ContextText); - if(ContextCur.context("WEBIG", 0.f, contextText)) + if (ContextCur.context("WEBIG", 0.f, contextText)) return; } - } - else - { - if (!selectedInstance.empty()) - { - for(uint j=0;jsetCursor("curs_default.tga"); selectedInstanceURL.clear(); } } + SlotUnderCursor = CLFECOMMON::INVALID_SLOT; } } @@ -896,7 +884,8 @@ void contextWebIG(bool rightClick, bool dblClick) CInterface3DShape *el= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object:scene3d:object_1")); if (el != NULL) { - el->setName(selectedInstance.getShapeName()); + //TODO: Fix that + //el->setName(selectedInstance.getShapeName()); el->setPosX(0.0f); } if (selectedInstanceURL.empty()) diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index 382f2f7e1..b46d7ce29 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -703,6 +703,57 @@ double CEntityManager::getInstanceColOrient(uint32 idx) return primitive->getOrientation(dynamicWI); } +CVector CEntityManager::getInstanceBBoxMin(uint32 idx) +{ + if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted) + return CVector(0,0,0); + + UInstance instance = _ShapeInstances[idx].Instance; + if (instance.empty()) + return CVector(0,0,0); + + NLMISC::CAABBox bbox; + _ShapeInstances[idx].Instance.getShapeAABBox(bbox); + + CVector bbox_min; + + if (bbox.getCenter() == CVector::Null) + bbox_min = CVector(-0.5f, -0.5f, -0.5f); + else + bbox_min = bbox.getMin(); + + bbox_min.x *= _ShapeInstances[idx].Instance.getScale().x; + bbox_min.y *= _ShapeInstances[idx].Instance.getScale().y; + bbox_min.z *= _ShapeInstances[idx].Instance.getScale().z; + + return bbox_min+_ShapeInstances[idx].Instance.getPos(); +} + +CVector CEntityManager::getInstanceBBoxMax(uint32 idx) +{ + if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted) + return CVector(0,0,0); + + UInstance instance = _ShapeInstances[idx].Instance; + if(instance.empty()) + return CVector(0,0,0); + + NLMISC::CAABBox bbox; + _ShapeInstances[idx].Instance.getShapeAABBox(bbox); + + CVector bbox_max; + + if (bbox.getCenter() == CVector::Null) + bbox_max = CVector(-0.5f, -0.5f, -0.5f); + else + bbox_max = bbox.getMax(); + + bbox_max.x *= _ShapeInstances[idx].Instance.getScale().x; + bbox_max.y *= _ShapeInstances[idx].Instance.getScale().y; + bbox_max.z *= _ShapeInstances[idx].Instance.getScale().z; + + return bbox_max+_ShapeInstances[idx].Instance.getPos(); +} bool CEntityManager::removeInstances() { @@ -756,14 +807,28 @@ bool CEntityManager::setupInstance(uint32 idx, const vector &keys, const } else if (param == "colorize") { - CRGBA c; - if( fromString( values[i], c ) ) + if (values[i] == "0") { for(uint j=0;j &keys, const } } } + else if (param == "skeleton") + { + // TODO + } + else if (param == "context") + { + _ShapeInstances[idx].ContextText = values[i]; + } + else if (param == "url") + { + _ShapeInstances[idx].ContextURL = values[i]; + } + else if (param == "move x" || param == "move y" || param == "move z") + { + float v; + CVector pos = getInstancePos(idx); + + if( getRelativeFloatFromString( values[i], v ) ) { + updateVector(param, pos, v, true); + } else { + updateVector(param, pos, v, false); + } + setInstancePos(idx, pos); + } + else if (param == "rot x" || param == "rot y" || param == "rot z") + { + + float v; + CVector rot = getInstanceRot(idx); + + if( getRelativeFloatFromString( values[i], v ) ) { + updateVector(param, rot, v, true); + } else { + updateVector(param, rot, v, false); + } + setInstanceRot(idx, rot); + } else if (param == "scale x" || param == "scale y" || param == "scale z") { float v; @@ -879,6 +981,10 @@ bool CEntityManager::setupInstance(uint32 idx, const vector &keys, const fromString(values[i], active); primitive->setObstacle(active); } + else if (param == "col obstacle") + { + + } } return true; @@ -933,7 +1039,16 @@ CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float bbox_max = bbox.getMax(); } - bbox.setMinMax((bbox_min*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos(), (bbox_max*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos()); + bbox_min.x *= _ShapeInstances[i].Instance.getScale().x; + bbox_min.y *= _ShapeInstances[i].Instance.getScale().y; + bbox_min.z *= _ShapeInstances[i].Instance.getScale().z; + + bbox_max.x *= _ShapeInstances[i].Instance.getScale().x; + bbox_max.y *= _ShapeInstances[i].Instance.getScale().y; + bbox_max.z *= _ShapeInstances[i].Instance.getScale().z; + + + bbox.setMinMax(bbox_min+_ShapeInstances[i].Instance.getPos(), bbox_max+_ShapeInstances[i].Instance.getPos()); if(bbox.intersect(pos, pos+dir*100.0f)) { diff --git a/code/ryzom/client/src/entities.h b/code/ryzom/client/src/entities.h index ed9b6ea6d..014020d6b 100644 --- a/code/ryzom/client/src/entities.h +++ b/code/ryzom/client/src/entities.h @@ -236,6 +236,8 @@ public: CVector getInstanceColPos(uint32 idx); CVector getInstanceColScale(uint32 idx); double getInstanceColOrient(uint32 idx); + 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);