make geom less slow

This commit is contained in:
floralrainfall 2023-07-16 01:08:37 -04:00
parent 13811c9d77
commit c92d01b2c9
2 changed files with 39 additions and 17 deletions

View File

@ -25,6 +25,8 @@ namespace RNR
Camera* getCurrentCamera() const;
void setCurrentCamera(Camera *value);
private:
void buildGeomInstance(Instance* instance);
bool m_instancingEnabled;
bool m_legacyDirty;
std::vector<Ogre::InstancedEntity*> m_objects;

View File

@ -46,27 +46,42 @@ namespace RNR
}
else
{
m_legacyGeom->addEntity(m_partEntity,
child_part->getCFrame().getPosition(),
Ogre::Quaternion(child_part->getCFrame().getRotation()),
child_part->getSize());
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()
{
if(!m_legacyDirty)
return;
m_legacyGeom->reset();
for(auto& child : *getChildren())
buildGeomInstance(child);
m_legacyGeom->build();
m_legacyDirty = false;
}
void Workspace::onChildRemoved(Instance* childRemoved)
{
PartInstance* child_part = dynamic_cast<PartInstance*>(childRemoved);
if(m_instancingEnabled)
{
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childRemoved->getObject();
if(child_ent)
{
PartInstance* child_part = dynamic_cast<PartInstance*>(childRemoved);
if(child_part)
{
child_ent->_getOwner()->removeInstancedEntity(child_ent);
@ -82,6 +97,11 @@ namespace RNR
delete child_ent;
}
}
else
{
}
}
Camera* Workspace::getCurrentCamera() const
{