mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:48:54 +02:00
Add ModelTree::findModelsInCube
This commit is contained in:
parent
6a53765a47
commit
d54e3741ed
4 changed files with 39 additions and 2 deletions
|
@ -387,6 +387,26 @@ public:
|
||||||
QVector<ModelItem*> _foundModels;
|
QVector<ModelItem*> _foundModels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ModelTree::findModelsInCube(const AACube& cube, QVector<ModelItem*>& foundModels) {
|
||||||
|
FindModelsInCubeArgs args(cube);
|
||||||
|
lockForRead();
|
||||||
|
recurseTreeWithOperation(findInCubeOperation, &args);
|
||||||
|
unlock();
|
||||||
|
// swap the two lists of model pointers instead of copy
|
||||||
|
foundModels.swap(args._foundModels);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModelTree::findInCubeOperation(OctreeElement* element, void* extraData) {
|
||||||
|
FindModelsInCubeArgs* args = static_cast< FindModelsInCubeArgs*>(extraData);
|
||||||
|
const AACube& elementCube = element->getAACube();
|
||||||
|
if (elementCube.touches(args->_cube)) {
|
||||||
|
ModelTreeElement* modelTreeElement = static_cast<ModelTreeElement*>(element);
|
||||||
|
modelTreeElement->getModelsInside(args->_cube, args->_foundModels);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool ModelTree::findInCubeForUpdateOperation(OctreeElement* element, void* extraData) {
|
bool ModelTree::findInCubeForUpdateOperation(OctreeElement* element, void* extraData) {
|
||||||
FindModelsInCubeArgs* args = static_cast< FindModelsInCubeArgs*>(extraData);
|
FindModelsInCubeArgs* args = static_cast< FindModelsInCubeArgs*>(extraData);
|
||||||
const AACube& elementCube = element->getAACube();
|
const AACube& elementCube = element->getAACube();
|
||||||
|
@ -398,7 +418,7 @@ bool ModelTree::findInCubeForUpdateOperation(OctreeElement* element, void* extra
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelTree::findModelsForUpdate(const AACube& cube, QVector<ModelItem*> foundModels) {
|
void ModelTree::findModelsForUpdate(const AACube& cube, QVector<ModelItem*>& foundModels) {
|
||||||
FindModelsInCubeArgs args(cube);
|
FindModelsInCubeArgs args(cube);
|
||||||
lockForRead();
|
lockForRead();
|
||||||
recurseTreeWithOperation(findInCubeForUpdateOperation, &args);
|
recurseTreeWithOperation(findInCubeForUpdateOperation, &args);
|
||||||
|
|
|
@ -63,12 +63,13 @@ public:
|
||||||
/// \param foundModels[out] vector of const ModelItem*
|
/// \param foundModels[out] vector of const ModelItem*
|
||||||
/// \remark Side effect: any initial contents in foundModels will be lost
|
/// \remark Side effect: any initial contents in foundModels will be lost
|
||||||
void findModels(const glm::vec3& center, float radius, QVector<const ModelItem*>& foundModels);
|
void findModels(const glm::vec3& center, float radius, QVector<const ModelItem*>& foundModels);
|
||||||
|
void findModelsInCube(const AACube& cube, QVector<ModelItem*>& foundModels);
|
||||||
|
|
||||||
/// finds all models that touch a cube
|
/// finds all models that touch a cube
|
||||||
/// \param cube the query cube
|
/// \param cube the query cube
|
||||||
/// \param foundModels[out] vector of non-const ModelItem*
|
/// \param foundModels[out] vector of non-const ModelItem*
|
||||||
/// \remark Side effect: any initial contents in models will be lost
|
/// \remark Side effect: any initial contents in models will be lost
|
||||||
void findModelsForUpdate(const AACube& cube, QVector<ModelItem*> foundModels);
|
void findModelsForUpdate(const AACube& cube, QVector<ModelItem*>& foundModels);
|
||||||
|
|
||||||
void addNewlyCreatedHook(NewlyCreatedModelHook* hook);
|
void addNewlyCreatedHook(NewlyCreatedModelHook* hook);
|
||||||
void removeNewlyCreatedHook(NewlyCreatedModelHook* hook);
|
void removeNewlyCreatedHook(NewlyCreatedModelHook* hook);
|
||||||
|
@ -92,6 +93,7 @@ private:
|
||||||
|
|
||||||
static bool sendModelsOperation(OctreeElement* element, void* extraData);
|
static bool sendModelsOperation(OctreeElement* element, void* extraData);
|
||||||
static bool updateOperation(OctreeElement* element, void* extraData);
|
static bool updateOperation(OctreeElement* element, void* extraData);
|
||||||
|
static bool findInCubeOperation(OctreeElement* element, void* extraData);
|
||||||
static bool findAndUpdateOperation(OctreeElement* element, void* extraData);
|
static bool findAndUpdateOperation(OctreeElement* element, void* extraData);
|
||||||
static bool findAndUpdateWithIDandPropertiesOperation(OctreeElement* element, void* extraData);
|
static bool findAndUpdateWithIDandPropertiesOperation(OctreeElement* element, void* extraData);
|
||||||
static bool findNearPointOperation(OctreeElement* element, void* extraData);
|
static bool findNearPointOperation(OctreeElement* element, void* extraData);
|
||||||
|
|
|
@ -399,6 +399,19 @@ void ModelTreeElement::getModels(const glm::vec3& searchPosition, float searchRa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelTreeElement::getModelsInside(const AACube& box, QVector<ModelItem*>& foundModels) {
|
||||||
|
QList<ModelItem>::iterator modelItr = _modelItems->begin();
|
||||||
|
QList<ModelItem>::iterator modelEnd = _modelItems->end();
|
||||||
|
AACube modelCube;
|
||||||
|
while(modelItr != modelEnd) {
|
||||||
|
ModelItem* model = &(*modelItr);
|
||||||
|
if (box.contains(model->getPosition())) {
|
||||||
|
foundModels.push_back(model);
|
||||||
|
}
|
||||||
|
++modelItr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModelTreeElement::getModelsForUpdate(const AACube& box, QVector<ModelItem*>& foundModels) {
|
void ModelTreeElement::getModelsForUpdate(const AACube& box, QVector<ModelItem*>& foundModels) {
|
||||||
QList<ModelItem>::iterator modelItr = _modelItems->begin();
|
QList<ModelItem>::iterator modelItr = _modelItems->begin();
|
||||||
QList<ModelItem>::iterator modelEnd = _modelItems->end();
|
QList<ModelItem>::iterator modelEnd = _modelItems->end();
|
||||||
|
|
|
@ -138,6 +138,8 @@ public:
|
||||||
/// \param models[out] vector of non-const ModelItem*
|
/// \param models[out] vector of non-const ModelItem*
|
||||||
void getModelsForUpdate(const AACube& box, QVector<ModelItem*>& foundModels);
|
void getModelsForUpdate(const AACube& box, QVector<ModelItem*>& foundModels);
|
||||||
|
|
||||||
|
void getModelsInside(const AACube& box, QVector<ModelItem*>& foundModels);
|
||||||
|
|
||||||
const ModelItem* getModelWithID(uint32_t id) const;
|
const ModelItem* getModelWithID(uint32_t id) const;
|
||||||
|
|
||||||
bool removeModelWithID(uint32_t id);
|
bool removeModelWithID(uint32_t id);
|
||||||
|
|
Loading…
Reference in a new issue