Simplify previous commit
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14242 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a6a336c94a
commit
229f7f199b
@ -145,9 +145,11 @@ void SkidMarks::update(float dt, bool force_skid_marks,
|
|||||||
float distance = 0.0f;
|
float distance = 0.0f;
|
||||||
if (m_current > 0)
|
if (m_current > 0)
|
||||||
{
|
{
|
||||||
Vec3 previousPoint = m_left[m_current - 1]->getMiddlePoint();
|
Vec3 start = m_left[m_current - 1]->getCenterStart();
|
||||||
Vec3 newPoint = (raycast_left.m_contactPointWS + raycast_right.m_contactPointWS)/2;
|
Vec3 newPoint = (raycast_left.m_contactPointWS + raycast_right.m_contactPointWS)/2;
|
||||||
distance = m_left[m_current - 1]->getDistance() + (newPoint - previousPoint).length();
|
// this linear distance does not account for the kart turning, it's true,
|
||||||
|
// but it produces good enough results
|
||||||
|
distance = (newPoint - start).length();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_left [m_current]->add(raycast_left.m_contactPointWS,
|
m_left [m_current]->add(raycast_left.m_contactPointWS,
|
||||||
@ -182,14 +184,14 @@ void SkidMarks::update(float dt, bool force_skid_marks,
|
|||||||
SkidMarkQuads *smq_left =
|
SkidMarkQuads *smq_left =
|
||||||
new SkidMarkQuads(raycast_left.m_contactPointWS,
|
new SkidMarkQuads(raycast_left.m_contactPointWS,
|
||||||
raycast_left.m_contactPointWS + delta,
|
raycast_left.m_contactPointWS + delta,
|
||||||
m_material, 0.0f, m_avoid_z_fighting, custom_color);
|
m_material, m_avoid_z_fighting, custom_color);
|
||||||
scene::SMesh *new_mesh = new scene::SMesh();
|
scene::SMesh *new_mesh = new scene::SMesh();
|
||||||
new_mesh->addMeshBuffer(smq_left);
|
new_mesh->addMeshBuffer(smq_left);
|
||||||
|
|
||||||
SkidMarkQuads *smq_right =
|
SkidMarkQuads *smq_right =
|
||||||
new SkidMarkQuads(raycast_right.m_contactPointWS - delta,
|
new SkidMarkQuads(raycast_right.m_contactPointWS - delta,
|
||||||
raycast_right.m_contactPointWS,
|
raycast_right.m_contactPointWS,
|
||||||
m_material, 0.0f, m_avoid_z_fighting, custom_color);
|
m_material, m_avoid_z_fighting, custom_color);
|
||||||
new_mesh->addMeshBuffer(smq_right);
|
new_mesh->addMeshBuffer(smq_right);
|
||||||
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh);
|
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -234,15 +236,13 @@ void SkidMarks::update(float dt, bool force_skid_marks,
|
|||||||
SkidMarks::SkidMarkQuads::SkidMarkQuads(const Vec3 &left,
|
SkidMarks::SkidMarkQuads::SkidMarkQuads(const Vec3 &left,
|
||||||
const Vec3 &right,
|
const Vec3 &right,
|
||||||
video::SMaterial *material,
|
video::SMaterial *material,
|
||||||
float distance,
|
|
||||||
float z_offset,
|
float z_offset,
|
||||||
video::SColor* custom_color)
|
video::SColor* custom_color)
|
||||||
: scene::SMeshBuffer()
|
: scene::SMeshBuffer()
|
||||||
{
|
{
|
||||||
m_middle_point = (left + right)/2;
|
m_center_start = (left + right)/2;
|
||||||
m_z_offset = z_offset;
|
m_z_offset = z_offset;
|
||||||
m_fade_out = 0.0f;
|
m_fade_out = 0.0f;
|
||||||
m_distance = distance;
|
|
||||||
|
|
||||||
m_start_color = (custom_color != NULL ? *custom_color :
|
m_start_color = (custom_color != NULL ? *custom_color :
|
||||||
video::SColor(255,
|
video::SColor(255,
|
||||||
@ -252,7 +252,7 @@ SkidMarks::SkidMarkQuads::SkidMarkQuads(const Vec3 &left,
|
|||||||
|
|
||||||
Material = *material;
|
Material = *material;
|
||||||
m_aabb = core::aabbox3df(left.toIrrVector());
|
m_aabb = core::aabbox3df(left.toIrrVector());
|
||||||
add(left, right, distance);
|
add(left, right, 0.0f);
|
||||||
|
|
||||||
|
|
||||||
} // SkidMarkQuads
|
} // SkidMarkQuads
|
||||||
|
@ -79,21 +79,20 @@ private:
|
|||||||
|
|
||||||
video::SColor m_start_color;
|
video::SColor m_start_color;
|
||||||
|
|
||||||
Vec3 m_middle_point;
|
/** Vector marking the start of the skidmarks (located between left and right wheel) */
|
||||||
float m_distance;
|
Vec3 m_center_start;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SkidMarkQuads (const Vec3 &left, const Vec3 &right,
|
SkidMarkQuads (const Vec3 &left, const Vec3 &right,
|
||||||
video::SMaterial *material, float distance,
|
video::SMaterial *material, float z_offset,
|
||||||
float z_offset, video::SColor* custom_color = NULL);
|
video::SColor* custom_color = NULL);
|
||||||
void add (const Vec3 &left,
|
void add (const Vec3 &left,
|
||||||
const Vec3 &right,
|
const Vec3 &right,
|
||||||
float distance);
|
float distance);
|
||||||
void fade (float f);
|
void fade (float f);
|
||||||
/** Returns the aabb of this skid mark quads. */
|
/** Returns the aabb of this skid mark quads. */
|
||||||
const core::aabbox3df &getAABB() { return m_aabb; }
|
const core::aabbox3df &getAABB() { return m_aabb; }
|
||||||
const Vec3& getMiddlePoint() const { return m_middle_point; }
|
const Vec3& getCenterStart() const { return m_center_start; }
|
||||||
float getDistance() const { return m_distance; }
|
|
||||||
}; // SkidMarkQuads
|
}; // SkidMarkQuads
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user