fix the issue with moving entities not being simulated makes motion smoother

This commit is contained in:
ZappoMan 2014-08-28 16:44:52 -07:00
parent c66ef90ca0
commit de968ba4f6
3 changed files with 21 additions and 21 deletions

View file

@ -97,7 +97,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
}
glm::quat rotation = getRotation();
if (_needsSimulation && _model->isActive()) {
if (needsSimulation() && _model->isActive()) {
_model->setScaleToFit(true, radius * 2.0f);
_model->setSnapModelToCenter(true);
_model->setRotation(rotation);
@ -108,7 +108,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
PerformanceTimer perfTimer("_model->simulate");
_model->simulate(0.0f);
}
_needsSimulation = false;
_needsInitialSimulation = false;
}
// TODO: should we allow entityItems to have alpha on their models?
@ -211,10 +211,10 @@ Model* RenderableModelEntityItem::getModel(EntityTreeRenderer* renderer) {
// then we need to let our renderer update our model for us.
if (_model && QUrl(getModelURL()) != _model->getURL()) {
result = _model = _myRenderer->updateModel(_model, getModelURL());
_needsSimulation = true;
_needsInitialSimulation = true;
} else if (!_model) { // if we don't yet have a model, then we want our renderer to allocate one
result = _model = _myRenderer->allocateModel(getModelURL());
_needsSimulation = true;
_needsInitialSimulation = true;
} else { // we already have the model we want...
result = _model;
}
@ -222,13 +222,18 @@ Model* RenderableModelEntityItem::getModel(EntityTreeRenderer* renderer) {
if (_model) {
_myRenderer->releaseModel(_model);
result = _model = NULL;
_needsSimulation = true;
_needsInitialSimulation = true;
}
}
return result;
}
bool RenderableModelEntityItem::needsSimulation() const {
SimulationState simulationState = getSimulationState();
return _needsInitialSimulation || simulationState == Moving || simulationState == Changing;
}

View file

@ -35,7 +35,7 @@ public:
RenderableModelEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
ModelEntityItem(entityItemID, properties),
_model(NULL),
_needsSimulation(true),
_needsInitialSimulation(true),
_needsModelReload(true),
_myRenderer(NULL) { };
@ -46,13 +46,15 @@ public:
ReadBitstreamToTreeParams& args,
EntityPropertyFlags& propertyFlags, bool overwriteLocalData);
virtual void somethingChangedNotification() { _needsSimulation = true; }
virtual void somethingChangedNotification() { _needsInitialSimulation = true; }
virtual void render(RenderArgs* args);
Model* getModel(EntityTreeRenderer* renderer);
private:
bool needsSimulation() const;
Model* _model;
bool _needsSimulation;
bool _needsInitialSimulation;
bool _needsModelReload;
EntityTreeRenderer* _myRenderer;
};

View file

@ -1,17 +1,5 @@
// REQUIRED:
1) Crash in delete model - deleting the geometry...
I think this is a cross threading issue... delete Model needs to be on same thread that created it.
-- change Model* RenderableModelEntityItem::getModel(); to call a new method on EntityTreeRenderer::newModel();
-- change RenderableModelEntityItem::~RenderableModelEntityItem() to call a new method on EntityTreeRenderer::deleteModel(Model*);
2) Moving models don't always move.. I think this relates to the render optimization...
need to make sure we re-simulate when a model is moving...
3) if velocity sends a model out of the domain - delete it
4) Test file save load for case where two siblings have more than MTU amount of data. I wonder if the fact that file save
@ -24,6 +12,8 @@
7) random crashes on moving (I think things going out of bounds???)
8) some jutter with moving entities
-- I think this might only happen with lots of models in an element or in view
this may be related to issue 13 below
9) test animation again...
@ -255,7 +245,10 @@
// DONE - * make sure that deleting a mortal but not yet dead entity works
// DONE - * make sure that newly "viewed" entities are correctly added to our simulation lists: mortal, changing, moving
// SOLVED -- 41) clear all entities when changing domains?
// SOLVED -- 42) Crash in delete model - deleting the geometry...
// SOLVED -- 43) Moving models don't always move.. I think this relates to the render optimization...
// need to make sure we re-simulate when a model is moving...
---------------- properties -----------------