make geom less slow
This commit is contained in:
parent
13811c9d77
commit
c92d01b2c9
|
|
@ -25,6 +25,8 @@ namespace RNR
|
||||||
Camera* getCurrentCamera() const;
|
Camera* getCurrentCamera() const;
|
||||||
void setCurrentCamera(Camera *value);
|
void setCurrentCamera(Camera *value);
|
||||||
private:
|
private:
|
||||||
|
void buildGeomInstance(Instance* instance);
|
||||||
|
|
||||||
bool m_instancingEnabled;
|
bool m_instancingEnabled;
|
||||||
bool m_legacyDirty;
|
bool m_legacyDirty;
|
||||||
std::vector<Ogre::InstancedEntity*> m_objects;
|
std::vector<Ogre::InstancedEntity*> m_objects;
|
||||||
|
|
|
||||||
|
|
@ -46,40 +46,60 @@ namespace RNR
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_legacyGeom->addEntity(m_partEntity,
|
|
||||||
child_part->getCFrame().getPosition(),
|
|
||||||
Ogre::Quaternion(child_part->getCFrame().getRotation()),
|
|
||||||
child_part->getSize());
|
|
||||||
m_legacyDirty = true;
|
m_legacyDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Workspace::buildGeomInstance(Instance* instance)
|
||||||
|
{
|
||||||
|
PartInstance* child_part = dynamic_cast<PartInstance*>(instance);
|
||||||
|
if(child_part)
|
||||||
|
m_legacyGeom->addEntity(m_partEntity,
|
||||||
|
child_part->getCFrame().getPosition(),
|
||||||
|
Ogre::Quaternion(child_part->getCFrame().getRotation()),
|
||||||
|
child_part->getSize());
|
||||||
|
for(auto& child : *instance->getChildren())
|
||||||
|
buildGeomInstance(child);
|
||||||
|
}
|
||||||
|
|
||||||
void Workspace::buildLegacyGeom()
|
void Workspace::buildLegacyGeom()
|
||||||
{
|
{
|
||||||
|
if(!m_legacyDirty)
|
||||||
|
return;
|
||||||
|
m_legacyGeom->reset();
|
||||||
|
for(auto& child : *getChildren())
|
||||||
|
buildGeomInstance(child);
|
||||||
m_legacyGeom->build();
|
m_legacyGeom->build();
|
||||||
m_legacyDirty = false;
|
m_legacyDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::onChildRemoved(Instance* childRemoved)
|
void Workspace::onChildRemoved(Instance* childRemoved)
|
||||||
{
|
{
|
||||||
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childRemoved->getObject();
|
PartInstance* child_part = dynamic_cast<PartInstance*>(childRemoved);
|
||||||
if(child_ent)
|
if(m_instancingEnabled)
|
||||||
{
|
{
|
||||||
PartInstance* child_part = dynamic_cast<PartInstance*>(childRemoved);
|
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childRemoved->getObject();
|
||||||
if(child_part)
|
if(child_ent)
|
||||||
{
|
{
|
||||||
child_ent->_getOwner()->removeInstancedEntity(child_ent);
|
if(child_part)
|
||||||
child_part->setObject(NULL);
|
|
||||||
|
|
||||||
auto child_it = std::find(m_objects.begin(), m_objects.end(), child_ent);
|
|
||||||
if (child_it != m_objects.end())
|
|
||||||
{
|
{
|
||||||
m_objects.erase(child_it);
|
child_ent->_getOwner()->removeInstancedEntity(child_ent);
|
||||||
}
|
child_part->setObject(NULL);
|
||||||
}
|
|
||||||
|
auto child_it = std::find(m_objects.begin(), m_objects.end(), child_ent);
|
||||||
|
if (child_it != m_objects.end())
|
||||||
|
{
|
||||||
|
m_objects.erase(child_it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete child_ent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
delete child_ent;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue