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,27 +46,42 @@ 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)
|
||||||
|
{
|
||||||
|
PartInstance* child_part = dynamic_cast<PartInstance*>(childRemoved);
|
||||||
|
if(m_instancingEnabled)
|
||||||
{
|
{
|
||||||
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childRemoved->getObject();
|
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childRemoved->getObject();
|
||||||
if(child_ent)
|
if(child_ent)
|
||||||
{
|
{
|
||||||
PartInstance* child_part = dynamic_cast<PartInstance*>(childRemoved);
|
|
||||||
if(child_part)
|
if(child_part)
|
||||||
{
|
{
|
||||||
child_ent->_getOwner()->removeInstancedEntity(child_ent);
|
child_ent->_getOwner()->removeInstancedEntity(child_ent);
|
||||||
|
|
@ -82,6 +97,11 @@ namespace RNR
|
||||||
delete child_ent;
|
delete child_ent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Camera* Workspace::getCurrentCamera() const
|
Camera* Workspace::getCurrentCamera() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue