Merge remote-tracking branch 'kcat/misc-cleanup'

actorid
Marc Zinnschlag 12 years ago
commit dcc55b60c3

@ -64,7 +64,7 @@ void Animation::destroyObjectList(Ogre::SceneManager *sceneMgr, NifOgre::ObjectL
Animation::Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node) Animation::Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node)
: mPtr(ptr) : mPtr(ptr)
, mCamera(NULL) , mCamera(NULL)
, mInsert(NULL) , mInsert(node)
, mSkelBase(NULL) , mSkelBase(NULL)
, mAccumRoot(NULL) , mAccumRoot(NULL)
, mNonAccumRoot(NULL) , mNonAccumRoot(NULL)
@ -74,20 +74,14 @@ Animation::Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node)
{ {
for(size_t i = 0;i < sNumGroups;i++) for(size_t i = 0;i < sNumGroups;i++)
mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this)); mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this));
mInsert = node->createChildSceneNode();
} }
Animation::~Animation() Animation::~Animation()
{ {
if(mInsert) mAnimSources.clear();
{
mAnimSources.clear();
Ogre::SceneManager *sceneMgr = mInsert->getCreator();
destroyObjectList(sceneMgr, mObjectRoot);
sceneMgr->destroySceneNode(mInsert); Ogre::SceneManager *sceneMgr = mInsert->getCreator();
} destroyObjectList(sceneMgr, mObjectRoot);
} }
@ -268,8 +262,13 @@ void Animation::addAnimSource(const std::string &model)
if(!mAccumRoot && grp == 0) if(!mAccumRoot && grp == 0)
{ {
mAccumRoot = mInsert;
mNonAccumRoot = dstval->getNode(); mNonAccumRoot = dstval->getNode();
mAccumRoot = mNonAccumRoot->getParent();
if(!mAccumRoot)
{
std::cerr<< "Non-Accum root for "<<mPtr.getCellRef().mRefID<<" is skeleton root??" <<std::endl;
mNonAccumRoot = NULL;
}
} }
ctrls[i].setSource(mAnimationValuePtr[grp]); ctrls[i].setSource(mAnimationValuePtr[grp]);
@ -984,10 +983,7 @@ ObjectAnimation::ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &mod
{ {
setObjectRoot(model, false); setObjectRoot(model, false);
Ogre::AxisAlignedBox bounds = getWorldBounds(); Ogre::Vector3 extents = getWorldBounds().getSize();
Ogre::Vector3 extents = bounds.getSize();
extents *= mInsert->getParentSceneNode()->getScale();
float size = std::max(std::max(extents.x, extents.y), extents.z); float size = std::max(std::max(extents.x, extents.y), extents.z);
bool small = (size < Settings::Manager::getInt("small object size", "Viewing distance")) && bool small = (size < Settings::Manager::getInt("small object size", "Viewing distance")) &&

@ -130,7 +130,10 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh)
// - the culling will be more inefficient // - the culling will be more inefficient
// If it is set too low: // If it is set too low:
// - there will be too many batches. // - there will be too many batches.
sg->setRegionDimensions(Ogre::Vector3(2500,2500,2500)); if(ptr.getCell()->isExterior())
sg->setRegionDimensions(Ogre::Vector3(2048,2048,2048));
else
sg->setRegionDimensions(Ogre::Vector3(1024,1024,1024));
sg->setVisibilityFlags(small ? RV_StaticsSmall : RV_Statics); sg->setVisibilityFlags(small ? RV_StaticsSmall : RV_Statics);

@ -29,7 +29,7 @@ namespace MWWorld
{ {
static const float sMaxSlope = 60.0f; static const float sMaxSlope = 60.0f;
static const float sStepSize = 30.0f; static const float sStepSize = 32.0f;
// Arbitrary number. To prevent infinite loops. They shouldn't happen but it's good to be prepared. // Arbitrary number. To prevent infinite loops. They shouldn't happen but it's good to be prepared.
static const int sMaxIterations = 8; static const int sMaxIterations = 8;
@ -48,16 +48,15 @@ namespace MWWorld
OEngine::Physic::ActorTracer tracer, stepper; OEngine::Physic::ActorTracer tracer, stepper;
stepper.doTrace(colobj, position, position+Ogre::Vector3(0.0f,0.0f,sStepSize), engine); stepper.doTrace(colobj, position, position+Ogre::Vector3(0.0f,0.0f,sStepSize), engine);
if(stepper.mFraction == 0.0f) if(stepper.mFraction < std::numeric_limits<float>::epsilon())
return false; return false;
tracer.doTrace(colobj, stepper.mEndPos, stepper.mEndPos + velocity*remainingTime, engine); tracer.doTrace(colobj, stepper.mEndPos, stepper.mEndPos + velocity*remainingTime, engine);
if(tracer.mFraction < std::numeric_limits<float>::epsilon() || if(tracer.mFraction < std::numeric_limits<float>::epsilon())
(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) > sMaxSlope))
return false; return false;
stepper.doTrace(colobj, tracer.mEndPos, tracer.mEndPos-Ogre::Vector3(0.0f,0.0f,sStepSize), engine); stepper.doTrace(colobj, tracer.mEndPos, tracer.mEndPos-Ogre::Vector3(0.0f,0.0f,sStepSize), engine);
if(getSlope(stepper.mPlaneNormal) <= sMaxSlope) if(stepper.mFraction < 1.0f && getSlope(stepper.mPlaneNormal) <= sMaxSlope)
{ {
// only step down onto semi-horizontal surfaces. don't step down onto the side of a house or a wall. // only step down onto semi-horizontal surfaces. don't step down onto the side of a house or a wall.
position = stepper.mEndPos; position = stepper.mEndPos;
@ -257,7 +256,7 @@ namespace MWWorld
return mEngine; return mEngine;
} }
std::pair<float, std::string> PhysicsSystem::getFacedHandle (MWWorld::World& world, float queryDistance) std::pair<float, std::string> PhysicsSystem::getFacedHandle(float queryDistance)
{ {
Ray ray = mRender.getCamera()->getCameraToViewportRay(0.5, 0.5); Ray ray = mRender.getCamera()->getCameraToViewportRay(0.5, 0.5);
@ -267,8 +266,7 @@ namespace MWWorld
btVector3 dir(dir_.x, dir_.y, dir_.z); btVector3 dir(dir_.x, dir_.y, dir_.z);
btVector3 dest = origin + dir * queryDistance; btVector3 dest = origin + dir * queryDistance;
std::pair <std::string, float> result; std::pair <std::string, float> result = mEngine->rayTest(origin, dest);
/*auto*/ result = mEngine->rayTest(origin, dest);
result.second *= queryDistance; result.second *= queryDistance;
return std::make_pair (result.second, result.first); return std::make_pair (result.second, result.first);
@ -339,24 +337,6 @@ namespace MWWorld
} }
btVector3 PhysicsSystem::getRayPoint(float extent)
{
//get a ray pointing to the center of the viewport
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
mRender.getViewport()->getWidth()/2,
mRender.getViewport()->getHeight()/2);
btVector3 result(centerRay.getPoint(extent).x,centerRay.getPoint(extent).y,centerRay.getPoint(extent).z);
return result;
}
btVector3 PhysicsSystem::getRayPoint(float extent, float mouseX, float mouseY)
{
//get a ray pointing to the center of the viewport
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(mouseX, mouseY);
btVector3 result(centerRay.getPoint(extent).x,centerRay.getPoint(extent).y,centerRay.getPoint(extent).z);
return result;
}
bool PhysicsSystem::castRay(const Vector3& from, const Vector3& to, bool raycastingObjectOnly,bool ignoreHeightMap) bool PhysicsSystem::castRay(const Vector3& from, const Vector3& to, bool raycastingObjectOnly,bool ignoreHeightMap)
{ {
btVector3 _from, _to; btVector3 _from, _to;

@ -56,7 +56,7 @@ namespace MWWorld
std::vector<std::string> getCollisions(const MWWorld::Ptr &ptr); ///< get handles this object collides with std::vector<std::string> getCollisions(const MWWorld::Ptr &ptr); ///< get handles this object collides with
Ogre::Vector3 traceDown(const MWWorld::Ptr &ptr); Ogre::Vector3 traceDown(const MWWorld::Ptr &ptr);
std::pair<float, std::string> getFacedHandle (MWWorld::World& world, float queryDistance); std::pair<float, std::string> getFacedHandle(float queryDistance);
std::pair<std::string,Ogre::Vector3> getHitContact(const std::string &name, std::pair<std::string,Ogre::Vector3> getHitContact(const std::string &name,
const Ogre::Vector3 &origin, const Ogre::Vector3 &origin,
const Ogre::Quaternion &orientation, const Ogre::Quaternion &orientation,
@ -64,10 +64,6 @@ namespace MWWorld
std::vector < std::pair <float, std::string> > getFacedHandles (float queryDistance); std::vector < std::pair <float, std::string> > getFacedHandles (float queryDistance);
std::vector < std::pair <float, std::string> > getFacedHandles (float mouseX, float mouseY, float queryDistance); std::vector < std::pair <float, std::string> > getFacedHandles (float mouseX, float mouseY, float queryDistance);
btVector3 getRayPoint(float extent);
btVector3 getRayPoint(float extent, float mouseX, float mouseY);
// cast ray, return true if it hit something. if raycasringObjectOnlt is set to false, it ignores NPCs and objects with no collisions. // cast ray, return true if it hit something. if raycasringObjectOnlt is set to false, it ignores NPCs and objects with no collisions.
bool castRay(const Ogre::Vector3& from, const Ogre::Vector3& to, bool raycastingObjectOnly = true,bool ignoreHeightMap = false); bool castRay(const Ogre::Vector3& from, const Ogre::Vector3& to, bool raycastingObjectOnly = true,bool ignoreHeightMap = false);

@ -761,7 +761,7 @@ namespace MWWorld
std::pair<float, std::string> result; std::pair<float, std::string> result;
if (!mRendering->occlusionQuerySupported()) if (!mRendering->occlusionQuerySupported())
result = mPhysics->getFacedHandle (*this, getMaxActivationDistance ()); result = mPhysics->getFacedHandle (getMaxActivationDistance ());
else else
result = std::make_pair (mFacedDistance, mFacedHandle); result = std::make_pair (mFacedDistance, mFacedHandle);

Loading…
Cancel
Save