mirror of
https://github.com/overte-org/overte.git
synced 2025-08-13 07:28:09 +02:00
get models actually rendering again
This commit is contained in:
parent
e540bef672
commit
ebe7182ab6
5 changed files with 34 additions and 30 deletions
|
@ -79,28 +79,31 @@ void EntityTreeRenderer::render(RenderMode renderMode) {
|
|||
//qDebug() << "******* DONE ******* EntityTreeRenderer::render() ************";
|
||||
}
|
||||
|
||||
const FBXGeometry* EntityTreeRenderer::getGeometryForEntity(const EntityItem& entityItem) {
|
||||
const FBXGeometry* EntityTreeRenderer::getGeometryForEntity(const EntityItem* entityItem) {
|
||||
const FBXGeometry* result = NULL;
|
||||
|
||||
Model* model = getModel(entityItem);
|
||||
if (model) {
|
||||
result = &model->getGeometry()->getFBXGeometry();
|
||||
if (entityItem->getType() == EntityTypes::Model) {
|
||||
const ModelEntityItem* modelEntityItem = static_cast<const ModelEntityItem*>(entityItem);
|
||||
|
||||
Model* model = getModel(modelEntityItem);
|
||||
if (model) {
|
||||
result = &model->getGeometry()->getFBXGeometry();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Model* EntityTreeRenderer::getModel(const EntityItem& entityItem) {
|
||||
Model* EntityTreeRenderer::getModel(const ModelEntityItem* modelEntityItem) {
|
||||
Model* model = NULL;
|
||||
|
||||
#if 0 //def HIDE_SUBCLASS_METHODS
|
||||
if (!entityItem.getModelURL().isEmpty()) {
|
||||
if (entityItem.isKnownID()) {
|
||||
if (_knownEntityItemModels.find(entityItem.getID()) != _knownEntityItemModels.end()) {
|
||||
model = _knownEntityItemModels[entityItem.getID()];
|
||||
if (QUrl(entityItem.getModelURL()) != model->getURL()) {
|
||||
if (!modelEntityItem->getModelURL().isEmpty()) {
|
||||
if (modelEntityItem->isKnownID()) {
|
||||
if (_knownEntityItemModels.find(modelEntityItem->getID()) != _knownEntityItemModels.end()) {
|
||||
model = _knownEntityItemModels[modelEntityItem->getID()];
|
||||
if (QUrl(modelEntityItem->getModelURL()) != model->getURL()) {
|
||||
delete model; // delete the old model...
|
||||
model = NULL;
|
||||
_knownEntityItemModels.remove(entityItem.getID());
|
||||
_knownEntityItemModels.remove(modelEntityItem->getID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,24 +113,24 @@ Model* EntityTreeRenderer::getModel(const EntityItem& entityItem) {
|
|||
if (QThread::currentThread() != thread()) {
|
||||
qDebug() << "about to call QMetaObject::invokeMethod(this, 'getModel', Qt::BlockingQueuedConnection,...";
|
||||
QMetaObject::invokeMethod(this, "getModel", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(Model*, model), Q_ARG(const EntityItem&, entityItem));
|
||||
Q_RETURN_ARG(Model*, model), Q_ARG(const ModelEntityItem*, modelEntityItem));
|
||||
qDebug() << "got it... model=" << model;
|
||||
return model;
|
||||
}
|
||||
|
||||
model = new Model();
|
||||
model->init();
|
||||
model->setURL(QUrl(entityItem.getModelURL()));
|
||||
_knownEntityItemModels[entityItem.getID()] = model;
|
||||
model->setURL(QUrl(modelEntityItem->getModelURL()));
|
||||
_knownEntityItemModels[modelEntityItem->getID()] = model;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (_unknownEntityItemModels.find(entityItem.getCreatorTokenID()) != _unknownEntityItemModels.end()) {
|
||||
model = _unknownEntityItemModels[entityItem.getCreatorTokenID()];
|
||||
if (QUrl(entityItem.getModelURL()) != model->getURL()) {
|
||||
if (_unknownEntityItemModels.find(modelEntityItem->getCreatorTokenID()) != _unknownEntityItemModels.end()) {
|
||||
model = _unknownEntityItemModels[modelEntityItem->getCreatorTokenID()];
|
||||
if (QUrl(modelEntityItem->getModelURL()) != model->getURL()) {
|
||||
delete model; // delete the old model...
|
||||
model = NULL;
|
||||
_unknownEntityItemModels.remove(entityItem.getID());
|
||||
_unknownEntityItemModels.remove(modelEntityItem->getID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,18 +138,17 @@ Model* EntityTreeRenderer::getModel(const EntityItem& entityItem) {
|
|||
// Make sure we only create new models on the thread that owns the EntityTreeRenderer
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "getModel", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(Model*, model), Q_ARG(const EntityItem&, entityItem));
|
||||
Q_RETURN_ARG(Model*, model), Q_ARG(const ModelEntityItem*, modelEntityItem));
|
||||
return model;
|
||||
}
|
||||
|
||||
model = new Model();
|
||||
model->init();
|
||||
model->setURL(QUrl(entityItem.getModelURL()));
|
||||
_unknownEntityItemModels[entityItem.getCreatorTokenID()] = model;
|
||||
model->setURL(QUrl(modelEntityItem->getModelURL()));
|
||||
_unknownEntityItemModels[modelEntityItem->getCreatorTokenID()] = model;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return model;
|
||||
}
|
||||
|
||||
|
@ -282,7 +284,7 @@ void EntityTreeRenderer::renderEntityTypeModel(EntityItem* entity, RenderArgs* a
|
|||
{
|
||||
const float alpha = 1.0f;
|
||||
|
||||
Model* model = getModel(*entityItem);
|
||||
Model* model = getModel(entityItem);
|
||||
|
||||
if (model) {
|
||||
model->setScaleToFit(true, radius * 2.0f);
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "renderer/Model.h"
|
||||
|
||||
class ModelEntityItem;
|
||||
|
||||
// Generic client side Octree renderer class.
|
||||
class EntityTreeRenderer : public OctreeRenderer, public EntityItemFBXService {
|
||||
Q_OBJECT
|
||||
|
@ -50,12 +52,12 @@ public:
|
|||
virtual void init();
|
||||
virtual void render(RenderMode renderMode = DEFAULT_RENDER_MODE);
|
||||
|
||||
virtual const FBXGeometry* getGeometryForEntity(const EntityItem& modelItem);
|
||||
virtual const FBXGeometry* getGeometryForEntity(const EntityItem* entityItem);
|
||||
|
||||
/// clears the tree
|
||||
virtual void clear();
|
||||
|
||||
Q_INVOKABLE Model* getModel(const EntityItem& modelItem);
|
||||
Q_INVOKABLE Model* getModel(const ModelEntityItem* modelEntityItem);
|
||||
|
||||
// renderers for various types of entities
|
||||
void renderEntityTypeBox(EntityItem* entity, RenderArgs* args);
|
||||
|
|
|
@ -74,7 +74,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID
|
|||
if (entity) {
|
||||
|
||||
// TODO: look into sitting points!!!
|
||||
//entity->setSittingPoints(_entityTree->getGeometryForEntity(*entity)->sittingPoints);
|
||||
//entity->setSittingPoints(_entityTree->getGeometryForEntity(entity)->sittingPoints);
|
||||
|
||||
results = entity->getProperties();
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
class EntityItemFBXService {
|
||||
public:
|
||||
virtual const FBXGeometry* getGeometryForEntity(const EntityItem& entityItem) = 0;
|
||||
virtual const FBXGeometry* getGeometryForEntity(const EntityItem* entityItem) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
void handleAddEntityResponse(const QByteArray& packet);
|
||||
|
||||
void setFBXService(EntityItemFBXService* service) { _fbxService = service; }
|
||||
const FBXGeometry* getGeometryForEntity(const EntityItem& entityItem) {
|
||||
const FBXGeometry* getGeometryForEntity(const EntityItem* entityItem) {
|
||||
return _fbxService ? _fbxService->getGeometryForEntity(entityItem) : NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con
|
|||
|
||||
// if the ray doesn't intersect with our cube, we can stop searching!
|
||||
if (entityCube.findRayIntersection(origin, direction, localDistance, localFace)) {
|
||||
const FBXGeometry* fbxGeometry = _myTree->getGeometryForEntity(*entity);
|
||||
const FBXGeometry* fbxGeometry = _myTree->getGeometryForEntity(entity);
|
||||
if (fbxGeometry && fbxGeometry->meshExtents.isValid()) {
|
||||
Extents extents = fbxGeometry->meshExtents;
|
||||
|
||||
|
|
Loading…
Reference in a new issue