Convert tabs to spaces and remove some trailing space.

computerfreak97 should check the editor settings, r9194 was full of noise.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9203 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
mbjornstk 2011-07-09 02:20:43 +00:00
parent 9d9ca9a3f4
commit 35a3e78b94
2 changed files with 126 additions and 126 deletions

View File

@ -79,142 +79,142 @@ void SkidMarks::reset()
*/ */
void SkidMarks::update(float dt) void SkidMarks::update(float dt)
{ {
//if the kart is gnu, then dont skid because he floats! //if the kart is gnu, then dont skid because he floats!
if (m_kart.getKartProperties()->getNonTranslatedName() != "Gnu") { if (m_kart.getKartProperties()->getNonTranslatedName() != "Gnu") {
float f = dt/stk_config->m_skid_fadeout_time*m_start_alpha; float f = dt/stk_config->m_skid_fadeout_time*m_start_alpha;
for(unsigned int i=0; i<m_left.size(); i++) for(unsigned int i=0; i<m_left.size(); i++)
{ {
m_left[i]->fade(f); m_left[i]->fade(f);
m_right[i]->fade(f); m_right[i]->fade(f);
} }
if(m_skid_marking) if(m_skid_marking)
{ {
// Get raycast information // Get raycast information
// ----------------------- // -----------------------
const btWheelInfo::RaycastInfo &raycast_right = const btWheelInfo::RaycastInfo &raycast_right =
m_kart.getVehicle()->getWheelInfo(2).m_raycastInfo; m_kart.getVehicle()->getWheelInfo(2).m_raycastInfo;
const btWheelInfo::RaycastInfo raycast_left = const btWheelInfo::RaycastInfo raycast_left =
m_kart.getVehicle()->getWheelInfo(3).m_raycastInfo; m_kart.getVehicle()->getWheelInfo(3).m_raycastInfo;
Vec3 delta = raycast_right.m_contactPointWS - raycast_left.m_contactPointWS; Vec3 delta = raycast_right.m_contactPointWS - raycast_left.m_contactPointWS;
// We were skid marking, but not anymore (either because the // We were skid marking, but not anymore (either because the
// wheels don't touch the ground, or the kart has stopped // wheels don't touch the ground, or the kart has stopped
// skidding). One special case: the physics force both wheels // skidding). One special case: the physics force both wheels
// on one axis to touch the ground. If only one wheel touches // on one axis to touch the ground. If only one wheel touches
// the ground, the 2nd one gets the same raycast result --> // the ground, the 2nd one gets the same raycast result -->
// delta is 0, and the behaviour is undefined. In this case // delta is 0, and the behaviour is undefined. In this case
// just stop doing skid marks as well. // just stop doing skid marks as well.
// --------------------------------------------------------- // ---------------------------------------------------------
if(!raycast_right.m_isInContact || !m_kart.getControls().m_drift || if(!raycast_right.m_isInContact || !m_kart.getControls().m_drift ||
fabsf(m_kart.getControls().m_steer) < 0.001f || fabsf(m_kart.getControls().m_steer) < 0.001f ||
delta.length2()<0.0001) delta.length2()<0.0001)
{ {
m_skid_marking = false; m_skid_marking = false;
// The vertices and indices will not change anymore (till these // The vertices and indices will not change anymore (till these
// skid mark quads are deleted) // skid mark quads are deleted)
m_left[m_current]->setHardwareMappingHint(scene::EHM_STATIC); m_left[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
m_right[m_current]->setHardwareMappingHint(scene::EHM_STATIC); m_right[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
return; return;
} }
// We are still skid marking, so add the latest quad // We are still skid marking, so add the latest quad
// ------------------------------------------------- // -------------------------------------------------
delta.normalize(); delta.normalize();
delta *= m_width; delta *= m_width;
m_left [m_current]->add(raycast_left.m_contactPointWS,
raycast_left.m_contactPointWS + delta);
m_right[m_current]->add(raycast_right.m_contactPointWS-delta,
raycast_right.m_contactPointWS);
// Adjust the boundary box of the mesh to include the
// adjusted aabb of its buffers.
core::aabbox3df aabb=m_nodes[m_current]->getMesh()->getBoundingBox();
aabb.addInternalBox(m_left[m_current]->getAABB());
aabb.addInternalBox(m_right[m_current]->getAABB());
m_nodes[m_current]->getMesh()->setBoundingBox(aabb);
return;
}
// Currently no skid marking m_left [m_current]->add(raycast_left.m_contactPointWS,
// ------------------------- raycast_left.m_contactPointWS + delta);
if((!m_kart.getControls().m_drift) || m_right[m_current]->add(raycast_right.m_contactPointWS-delta,
(fabsf(m_kart.getControls().m_steer) < 0.001f)) return; // no skidmarking raycast_right.m_contactPointWS);
// Adjust the boundary box of the mesh to include the
// not turning enough, don't draw skidmarks if kart is going straight ahead // adjusted aabb of its buffers.
// this is even stricter for Ai karts, since they tend to use LOTS of skidding core::aabbox3df aabb=m_nodes[m_current]->getMesh()->getBoundingBox();
const float min_skid_angle = m_kart.getController()->isPlayerController() ? 0.55f : 0.95f; aabb.addInternalBox(m_left[m_current]->getAABB());
if( fabsf(m_kart.getSteerPercent()) < min_skid_angle) return; aabb.addInternalBox(m_right[m_current]->getAABB());
m_nodes[m_current]->getMesh()->setBoundingBox(aabb);
// Start new skid marks return;
// -------------------- }
const btWheelInfo::RaycastInfo &raycast_right =
m_kart.getVehicle()->getWheelInfo(2).m_raycastInfo;
// No skidmarking if wheels don't have contact
if(!raycast_right.m_isInContact) return;
const btWheelInfo::RaycastInfo raycast_left = // Currently no skid marking
m_kart.getVehicle()->getWheelInfo(3).m_raycastInfo; // -------------------------
if((!m_kart.getControls().m_drift) ||
(fabsf(m_kart.getControls().m_steer) < 0.001f)) return; // no skidmarking
Vec3 delta = raycast_right.m_contactPointWS - raycast_left.m_contactPointWS; // not turning enough, don't draw skidmarks if kart is going straight ahead
// Special case: only one wheel on one axis touches the ground --> physics // this is even stricter for Ai karts, since they tend to use LOTS of skidding
// set both wheels to touch the same spot --> delta = 0. In this case, const float min_skid_angle = m_kart.getController()->isPlayerController() ? 0.55f : 0.95f;
// don't start skidmarks. if( fabsf(m_kart.getSteerPercent()) < min_skid_angle) return;
if(delta.length2()<0.0001) return;
delta.normalize();
delta *= m_width;
SkidMarkQuads *smq_left = new SkidMarkQuads(raycast_left.m_contactPointWS, // Start new skid marks
raycast_left.m_contactPointWS + delta, // --------------------
m_material, m_avoid_z_fighting); const btWheelInfo::RaycastInfo &raycast_right =
scene::SMesh *new_mesh = new scene::SMesh(); m_kart.getVehicle()->getWheelInfo(2).m_raycastInfo;
new_mesh->addMeshBuffer(smq_left); // No skidmarking if wheels don't have contact
if(!raycast_right.m_isInContact) return;
SkidMarkQuads *smq_right = new SkidMarkQuads(raycast_right.m_contactPointWS const btWheelInfo::RaycastInfo raycast_left =
- delta, m_kart.getVehicle()->getWheelInfo(3).m_raycastInfo;
raycast_right.m_contactPointWS,
m_material,
m_avoid_z_fighting);
new_mesh->addMeshBuffer(smq_right);
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh);
#ifdef DEBUG
std::string debug_name = m_kart.getIdent()+" (skid-mark)";
new_node->setName(debug_name.c_str());
#endif
// We don't keep a reference to the mesh here, so we have to decrement
// the reference count (which is set to 1 when doing "new SMesh()".
// The scene node will keep the mesh alive.
new_mesh->drop();
m_current++;
if(m_current>=stk_config->m_max_skidmarks)
m_current = 0;
if(m_current>=(int)m_left.size())
{
m_left. push_back (smq_left );
m_right.push_back (smq_right);
m_nodes.push_back (new_node);
}
else
{
irr_driver->removeNode(m_nodes[m_current]);
// Not necessary to delete m_nodes: removeNode
// deletes the node since its refcount reaches zero.
m_left[m_current]->drop();
m_right[m_current]->drop();
m_left [m_current] = smq_left; Vec3 delta = raycast_right.m_contactPointWS - raycast_left.m_contactPointWS;
m_right [m_current] = smq_right; // Special case: only one wheel on one axis touches the ground --> physics
m_nodes [m_current] = new_node; // set both wheels to touch the same spot --> delta = 0. In this case,
} // don't start skidmarks.
if(delta.length2()<0.0001) return;
delta.normalize();
delta *= m_width;
m_skid_marking = true; SkidMarkQuads *smq_left = new SkidMarkQuads(raycast_left.m_contactPointWS,
// More triangles are added each frame, so for now leave it raycast_left.m_contactPointWS + delta,
// to stream. m_material, m_avoid_z_fighting);
m_left[m_current]->setHardwareMappingHint(scene::EHM_STREAM); scene::SMesh *new_mesh = new scene::SMesh();
m_right[m_current]->setHardwareMappingHint(scene::EHM_STREAM); new_mesh->addMeshBuffer(smq_left);
}
SkidMarkQuads *smq_right = new SkidMarkQuads(raycast_right.m_contactPointWS
- delta,
raycast_right.m_contactPointWS,
m_material,
m_avoid_z_fighting);
new_mesh->addMeshBuffer(smq_right);
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh);
#ifdef DEBUG
std::string debug_name = m_kart.getIdent()+" (skid-mark)";
new_node->setName(debug_name.c_str());
#endif
// We don't keep a reference to the mesh here, so we have to decrement
// the reference count (which is set to 1 when doing "new SMesh()".
// The scene node will keep the mesh alive.
new_mesh->drop();
m_current++;
if(m_current>=stk_config->m_max_skidmarks)
m_current = 0;
if(m_current>=(int)m_left.size())
{
m_left. push_back (smq_left );
m_right.push_back (smq_right);
m_nodes.push_back (new_node);
}
else
{
irr_driver->removeNode(m_nodes[m_current]);
// Not necessary to delete m_nodes: removeNode
// deletes the node since its refcount reaches zero.
m_left[m_current]->drop();
m_right[m_current]->drop();
m_left [m_current] = smq_left;
m_right [m_current] = smq_right;
m_nodes [m_current] = new_node;
}
m_skid_marking = true;
// More triangles are added each frame, so for now leave it
// to stream.
m_left[m_current]->setHardwareMappingHint(scene::EHM_STREAM);
m_right[m_current]->setHardwareMappingHint(scene::EHM_STREAM);
}
} // update } // update
//============================================================================= //=============================================================================

View File

@ -334,7 +334,7 @@ public:
*/ */
const wchar_t* getName() const {return translations->w_gettext(m_name.c_str()); } const wchar_t* getName() const {return translations->w_gettext(m_name.c_str()); }
const std::string getNonTranslatedName() const {return m_name;} const std::string getNonTranslatedName() const {return m_name;}
/** Returns the internal identifier of this kart. */ /** Returns the internal identifier of this kart. */
const std::string& getIdent () const {return m_ident; } const std::string& getIdent () const {return m_ident; }