static geometry

This commit is contained in:
floralrainfall 2023-07-16 00:35:42 -04:00
parent 5404460fce
commit 835e481330
3 changed files with 46 additions and 20 deletions

View File

@ -20,13 +20,18 @@ namespace RNR
virtual void onChildAdded(RNR::Instance* childAdded);
virtual void onChildRemoved(RNR::Instance* childRemoved);
void buildLegacyGeom();
Camera* getCurrentCamera() const;
void setCurrentCamera(Camera *value);
private:
bool m_instancingEnabled;
bool m_legacyDirty;
std::vector<Ogre::InstancedEntity*> m_objects;
Ogre::StaticGeometry* m_legacyGeom; // use in case of InstanceManager either not working or not being supported
Ogre::InstanceManager* m_instMan;
Ogre::SceneNode* m_worldspawn;
Ogre::Entity* m_partEntity;
std::shared_ptr<Camera> currentCamera;
};

View File

@ -7,17 +7,21 @@ namespace RNR
{
Workspace::Workspace() : ModelInstance()
{
m_instancingEnabled = true;
m_instancingEnabled = false;
setName("Workspace");
m_instMan = world->getOgreSceneManager()->createInstanceManager("workspacePartInstanceManager", "fonts/Cube.mesh", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::InstanceManager::InstancingTechnique::HWInstancingBasic, 255);
m_instMan->setNumCustomParams(2);
m_worldspawn = world->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode();
m_legacyGeom = world->getOgreSceneManager()->createStaticGeometry("workspaceGeom");
m_partEntity = world->getOgreSceneManager()->createEntity("fonts/Cube.mesh");
}
void Workspace::onChildAdded(Instance* childAdded)
{
PartInstance* child_part = dynamic_cast<PartInstance*>(childAdded);
if(child_part)
{
if(m_instancingEnabled)
{
Ogre::InstancedEntity* child_ent = (Ogre::InstancedEntity*)childAdded->getObject();
if(!child_ent)
@ -40,6 +44,21 @@ namespace RNR
child_ent->setCustomParam(1, child_part->getColor());
child_ent->setCastShadows(true);
}
else
{
m_legacyGeom->addEntity(m_partEntity,
child_part->getCFrame().getPosition(),
Ogre::Quaternion(child_part->getCFrame().getRotation()),
child_part->getSize());
m_legacyDirty = true;
}
}
}
void Workspace::buildLegacyGeom()
{
m_legacyGeom->build();
m_legacyDirty = false;
}
void Workspace::onChildRemoved(Instance* childRemoved)

View File

@ -15,6 +15,8 @@ namespace RNR
m_datamodel->setName("DataModel");
m_workspace = new Workspace();
m_workspace->setParent(m_datamodel);
load("/home/caesium/Downloads/Telegram Desktop/Destroy-History-1.rbxl");
}
World::~World()
@ -95,6 +97,6 @@ namespace RNR
void World::update()
{
//
m_workspace->buildLegacyGeom();
}
}