Browse Source

Clean up plDistributor max/pl point interop

There were two terrible things here:
* Some nasty pointer-based casting
* Storing references to temporaries

Unfortunately, storing addrs of temps was happening through a helper
function, so VS won't warn here. I think I caught all the cases where
those functions were being used wrongly, but I can't be sure until
coverity runs on this commit.
Branan Purvine-Riley 11 years ago committed by Darryl Pogue
parent
commit
613b001678
  1. 13
      Sources/Tools/MaxConvert/plDistributor.cpp

13
Sources/Tools/MaxConvert/plDistributor.cpp

@ -83,8 +83,11 @@ static const float kMaxHeight = 10.f;
// overall rnd - overall probability that a candidate seed point (passing all other criteria) will be used
//
static inline hsPoint3& hsP3(const Point3& p) { return *(hsPoint3*)&p; }
static inline hsVector3& hsV3(const Point3& p) { return *(hsVector3*)&p; }
static inline const hsPoint3& hsP3(const Point3& p) { return reinterpret_cast<const hsPoint3&>(p); }
static inline const hsVector3& hsV3(const Point3& p) { return reinterpret_cast<const hsVector3&>(p); }
static inline hsPoint3& hsP3(Point3& p) { return reinterpret_cast<hsPoint3&>(p); }
static inline hsVector3& hsV3(Point3& p) { return reinterpret_cast<hsVector3&>(p); }
static inline Matrix3 Transpose(const Matrix3& m)
{
return Matrix3(m.GetColumn3(0), m.GetColumn3(1), m.GetColumn3(2), Point3(0,0,0));
@ -1010,9 +1013,9 @@ BOOL plDistributor::IProjectVertex(const Point3& pt, const Point3& dir, float ma
for( i = 0; i < faces.Count(); i++ )
{
int iFace = faces[i];
const hsPoint3& p0 = hsP3(fSurfMesh->getVert(fSurfMesh->faces[iFace].getVert(0)) * fSurfToWorld);
const hsPoint3& p1 = hsP3(fSurfMesh->getVert(fSurfMesh->faces[iFace].getVert(1)) * fSurfToWorld);
const hsPoint3& p2 = hsP3(fSurfMesh->getVert(fSurfMesh->faces[iFace].getVert(2)) * fSurfToWorld);
hsPoint3 p0 = hsP3(fSurfMesh->getVert(fSurfMesh->faces[iFace].getVert(0)) * fSurfToWorld);
hsPoint3 p1 = hsP3(fSurfMesh->getVert(fSurfMesh->faces[iFace].getVert(1)) * fSurfToWorld);
hsPoint3 p2 = hsP3(fSurfMesh->getVert(fSurfMesh->faces[iFace].getVert(2)) * fSurfToWorld);
Point3 plnPt = pt;
if( triUtil.ProjectOntoPlaneAlongVector(p0, p1, p2, hsV3(dir), hsP3(plnPt)) )

Loading…
Cancel
Save