Fix skid mark on wall surface
This commit is contained in:
parent
382905716f
commit
3f86722181
@ -153,9 +153,9 @@ void SkidMarks::update(float dt, bool force_skid_marks,
|
|||||||
float distance = (newPoint - start).length();
|
float distance = (newPoint - start).length();
|
||||||
|
|
||||||
m_left [m_current]->add(raycast_left-delta, raycast_left+delta,
|
m_left [m_current]->add(raycast_left-delta, raycast_left+delta,
|
||||||
distance);
|
m_kart.getNormal(), distance);
|
||||||
m_right[m_current]->add(raycast_right-delta, raycast_right+delta,
|
m_right[m_current]->add(raycast_right-delta, raycast_right+delta,
|
||||||
distance);
|
m_kart.getNormal(), distance);
|
||||||
// Adjust the boundary box of the mesh to include the
|
// Adjust the boundary box of the mesh to include the
|
||||||
// adjusted aabb of its buffers.
|
// adjusted aabb of its buffers.
|
||||||
core::aabbox3df aabb=m_nodes[m_current]->getMesh()
|
core::aabbox3df aabb=m_nodes[m_current]->getMesh()
|
||||||
@ -180,14 +180,16 @@ void SkidMarks::update(float dt, bool force_skid_marks,
|
|||||||
delta *= m_width*0.5f;
|
delta *= m_width*0.5f;
|
||||||
|
|
||||||
SkidMarkQuads *smq_left =
|
SkidMarkQuads *smq_left =
|
||||||
new SkidMarkQuads(raycast_left-delta, raycast_left+delta ,
|
new SkidMarkQuads(raycast_left-delta, raycast_left+delta,
|
||||||
m_material, m_avoid_z_fighting, custom_color);
|
m_kart.getNormal(), 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-delta, raycast_right+delta,
|
new SkidMarkQuads(raycast_right-delta, raycast_right+delta,
|
||||||
m_material, m_avoid_z_fighting, custom_color);
|
m_kart.getNormal(), 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, "skidmark");
|
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh, "skidmark");
|
||||||
if (STKMeshSceneNode* stkm = dynamic_cast<STKMeshSceneNode*>(new_node))
|
if (STKMeshSceneNode* stkm = dynamic_cast<STKMeshSceneNode*>(new_node))
|
||||||
@ -233,6 +235,7 @@ 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,
|
||||||
|
const Vec3 &normal,
|
||||||
video::SMaterial *material,
|
video::SMaterial *material,
|
||||||
float z_offset,
|
float z_offset,
|
||||||
video::SColor* custom_color)
|
video::SColor* custom_color)
|
||||||
@ -250,7 +253,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, 0.0f);
|
add(left, right, normal, 0.0f);
|
||||||
|
|
||||||
|
|
||||||
} // SkidMarkQuads
|
} // SkidMarkQuads
|
||||||
@ -261,6 +264,7 @@ SkidMarks::SkidMarkQuads::SkidMarkQuads(const Vec3 &left,
|
|||||||
*/
|
*/
|
||||||
void SkidMarks::SkidMarkQuads::add(const Vec3 &left,
|
void SkidMarks::SkidMarkQuads::add(const Vec3 &left,
|
||||||
const Vec3 &right,
|
const Vec3 &right,
|
||||||
|
const Vec3 &normal,
|
||||||
float distance)
|
float distance)
|
||||||
{
|
{
|
||||||
// The skid marks must be raised slightly higher, otherwise it blends
|
// The skid marks must be raised slightly higher, otherwise it blends
|
||||||
@ -280,13 +284,11 @@ void SkidMarks::SkidMarkQuads::add(const Vec3 &left,
|
|||||||
Vertices[n - 2].Color.setAlpha(m_start_alpha);
|
Vertices[n - 2].Color.setAlpha(m_start_alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
v.Pos = left.toIrrVector();
|
v.Pos = Vec3(left + normal * m_z_offset).toIrrVector();
|
||||||
v.Pos.Y += m_z_offset;
|
v.Normal = normal.toIrrVector();
|
||||||
v.Normal = core::vector3df(0, 1, 0);
|
|
||||||
v.TCoords = core::vector2df(0.0f, distance*0.5f);
|
v.TCoords = core::vector2df(0.0f, distance*0.5f);
|
||||||
Vertices.push_back(v);
|
Vertices.push_back(v);
|
||||||
v.Pos = right.toIrrVector();
|
v.Pos = Vec3(right + normal * m_z_offset).toIrrVector();
|
||||||
v.Pos.Y += m_z_offset;
|
|
||||||
v.TCoords = core::vector2df(1.0f, distance*0.5f);
|
v.TCoords = core::vector2df(1.0f, distance*0.5f);
|
||||||
Vertices.push_back(v);
|
Vertices.push_back(v);
|
||||||
// Out of the box Irrlicht only supports triangle meshes and not
|
// Out of the box Irrlicht only supports triangle meshes and not
|
||||||
|
@ -85,10 +85,11 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
SkidMarkQuads (const Vec3 &left, const Vec3 &right,
|
SkidMarkQuads (const Vec3 &left, const Vec3 &right,
|
||||||
video::SMaterial *material, float z_offset,
|
const Vec3 &normal, video::SMaterial *material,
|
||||||
video::SColor* custom_color = NULL);
|
float z_offset, video::SColor* custom_color = NULL);
|
||||||
void add (const Vec3 &left,
|
void add (const Vec3 &left,
|
||||||
const Vec3 &right,
|
const Vec3 &right,
|
||||||
|
const Vec3 &normal,
|
||||||
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. */
|
||||||
|
Loading…
Reference in New Issue
Block a user