Improved optimsiation for particle systems to allow
better culling. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2534 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
fbdde1aa76
commit
d2866bb42e
@ -223,12 +223,12 @@ void ParticleSystem::update ( float t )
|
|||||||
// center to get the correct maximum distance, which is the radius).
|
// center to get the correct maximum distance, which is the radius).
|
||||||
Vec3 center = 0.5*(xyz_min+xyz_max);
|
Vec3 center = 0.5*(xyz_min+xyz_max);
|
||||||
bsphere.setCenter(center.toFloat());
|
bsphere.setCenter(center.toFloat());
|
||||||
float radius = xyz_max.getX() - xyz_min.getX();
|
float diameter = xyz_max.getX() - xyz_min.getX();
|
||||||
radius = std::max(radius, xyz_max.getY() - xyz_min.getY());
|
diameter = std::max(diameter, xyz_max.getY() - xyz_min.getY());
|
||||||
radius = std::max(radius, xyz_max.getZ() - xyz_min.getZ());
|
diameter = std::max(diameter, xyz_max.getZ() - xyz_min.getZ());
|
||||||
if(radius<0) radius = 0; // happens if no particles exist.
|
if(diameter<0) diameter= 0; // happens if no particles exist.
|
||||||
// add the size of the actual quad to the radius on both ends
|
// add the size of the actual quad to the radius on both ends
|
||||||
bsphere.setRadius((radius+2*m_size)*1.733f); // 1.733 approx. sqrt(3)
|
bsphere.setRadius((diameter*0.5f+2*m_size)*1.733f); // 1.733 approx. sqrt(3)
|
||||||
bsphere_is_invalid = 0;
|
bsphere_is_invalid = 0;
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user