1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-03 17:41:32 +00:00

Improve scene loading performance by creating collision objects with the correct rotation right away instead of adjusting it later

This commit is contained in:
scrawl 2017-02-04 15:12:01 +01:00
parent 739a76f5fb
commit 1447bfa215

View file

@ -29,25 +29,11 @@
namespace namespace
{ {
void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, void setNodeRotation(const MWWorld::Ptr& ptr, MWRender::RenderingManager& rendering, bool inverseRotationOrder)
MWRender::RenderingManager& rendering)
{ {
std::string model = Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getModel(ptr), rendering.getResourceSystem()->getVFS()); if (!ptr.getRefData().getBaseNode())
std::string id = ptr.getCellRef().getRefId(); return;
if (id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker")
model = ""; // marker objects that have a hardcoded function in the game logic, should be hidden from the player
ptr.getClass().insertObjectRendering(ptr, model, rendering);
ptr.getClass().insertObject (ptr, model, physics);
if (ptr.getClass().isActor())
rendering.addWaterRippleEmitter(ptr);
}
void updateObjectRotation (const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
MWRender::RenderingManager& rendering, bool inverseRotationOrder)
{
if (ptr.getRefData().getBaseNode() != NULL)
{
osg::Quat worldRotQuat(ptr.getRefData().getPosition().rot[2], osg::Vec3(0,0,-1)); osg::Quat worldRotQuat(ptr.getRefData().getPosition().rot[2], osg::Vec3(0,0,-1));
if (!ptr.getClass().isActor()) if (!ptr.getClass().isActor())
{ {
@ -61,8 +47,29 @@ namespace
} }
rendering.rotateObject(ptr, worldRotQuat); rendering.rotateObject(ptr, worldRotQuat);
physics.updateRotation(ptr);
} }
void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
MWRender::RenderingManager& rendering)
{
std::string model = Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getModel(ptr), rendering.getResourceSystem()->getVFS());
std::string id = ptr.getCellRef().getRefId();
if (id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker")
model = ""; // marker objects that have a hardcoded function in the game logic, should be hidden from the player
ptr.getClass().insertObjectRendering(ptr, model, rendering);
setNodeRotation(ptr, rendering, false);
ptr.getClass().insertObject (ptr, model, physics);
if (ptr.getClass().isActor())
rendering.addWaterRippleEmitter(ptr);
}
void updateObjectRotation (const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
MWRender::RenderingManager& rendering, bool inverseRotationOrder)
{
setNodeRotation(ptr, rendering, inverseRotationOrder);
physics.updateRotation(ptr);
} }
void updateObjectScale(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, void updateObjectScale(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
@ -130,7 +137,6 @@ namespace
try try
{ {
addObject(ptr, mPhysics, mRendering); addObject(ptr, mPhysics, mRendering);
updateObjectRotation(ptr, mPhysics, mRendering, false);
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
@ -602,7 +608,6 @@ namespace MWWorld
try try
{ {
addObject(ptr, *mPhysics, mRendering); addObject(ptr, *mPhysics, mRendering);
updateObjectRotation(ptr, false);
MWBase::Environment::get().getWorld()->scaleObject(ptr, ptr.getCellRef().getScale()); MWBase::Environment::get().getWorld()->scaleObject(ptr, ptr.getCellRef().getScale());
} }
catch (std::exception& e) catch (std::exception& e)