Use collision shape for RSM size.

This commit is contained in:
vlj
2014-08-10 22:05:00 +02:00
parent b2e08c94a7
commit 0f5effc2d9
2 changed files with 10 additions and 4 deletions

View File

@@ -41,6 +41,7 @@
#include "items/item_manager.hpp"
#include "modes/world.hpp"
#include "physics/physics.hpp"
#include "physics/triangle_mesh.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
#include "utils/helpers.hpp"
@@ -601,8 +602,12 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
if (World::getWorld() && World::getWorld()->getTrack())
{
const Vec3 *vmin, *vmax;
World::getWorld()->getTrack()->getAABB(&vmin, &vmax);
btVector3 btmin, btmax;
if (World::getWorld()->getTrack()->getPtrTriangleMesh())
{
World::getWorld()->getTrack()->getTriangleMesh().getCollisionShape().getAabb(btTransform::getIdentity(), btmin, btmax);
}
const Vec3 vmin = btmin , vmax = btmax;
// Build the 3 ortho projection (for the 3 shadow resolution levels)
for (unsigned i = 0; i < 4; i++)
@@ -640,7 +645,7 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
memcpy(m_shadows_cam[i], tmp, 24 * sizeof(float));
const core::aabbox3df smallcambox = camnode->
getViewFrustum()->getBoundingBox();
core::aabbox3df trackbox(vmin->toIrrVector(), vmax->toIrrVector() -
core::aabbox3df trackbox(vmin.toIrrVector(), vmax.toIrrVector() -
core::vector3df(0, 30, 0));
// Set up a nice ortho projection that contains our camera frustum
@@ -677,7 +682,7 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
}
{
core::aabbox3df trackbox(vmin->toIrrVector(), vmax->toIrrVector() -
core::aabbox3df trackbox(vmin.toIrrVector(), vmax.toIrrVector() -
core::vector3df(0, 30, 0));
if (trackbox.MinEdge.X != trackbox.MaxEdge.X &&
trackbox.MinEdge.Y != trackbox.MaxEdge.Y &&

View File

@@ -548,6 +548,7 @@ public:
float getCameraFar() const { return m_camera_far; }
// ------------------------------------------------------------------------
/** Returns the triangle mesh for this track. */
const TriangleMesh *getPtrTriangleMesh() const { return m_track_mesh; }
const TriangleMesh& getTriangleMesh() const {return *m_track_mesh; }
// ------------------------------------------------------------------------
/** Returns the graphical effect mesh for this track. */