Procházet zdrojové kódy

uninitialized variables-collision

AzaezelX před 5 roky
rodič
revize
e9415a0994

+ 2 - 2
Engine/source/T3D/convexShape.cpp

@@ -92,12 +92,12 @@ void ConvexShapeCollisionConvex::getFeatures( const MatrixF &mat, const VectorF
 	if ( pShape->mGeometry.points.empty() )
 	{
 		cf->material = 0;
-		cf->object = NULL;
+		cf->mObject = NULL;
 		return;
 	}
 
 	cf->material = 0;
-	cf->object = mObject;
+	cf->mObject = mObject;
 
 	// Simple implementation... Add all Points, Edges and Faces.
 

+ 1 - 1
Engine/source/T3D/tsStatic.cpp

@@ -1486,7 +1486,7 @@ void TSStaticPolysoupConvex::getPolyList(AbstractPolyList* list)
 void TSStaticPolysoupConvex::getFeatures(const MatrixF& mat, const VectorF& n, ConvexFeature* cf)
 {
    cf->material = 0;
-   cf->object = mObject;
+   cf->mObject = mObject;
 
    // For a tetrahedron this is pretty easy... first
    // convert everything into world space.

+ 1 - 1
Engine/source/collision/boxConvex.cpp

@@ -85,7 +85,7 @@ inline bool isOnPlane(const Point3F& p,PlaneF& plane)
 void BoxConvex::getFeatures(const MatrixF& mat,const VectorF& n, ConvexFeature* cf)
 {
    cf->material = 0;
-   cf->object = mObject;
+   cf->mObject = mObject;
 
    S32 v = 0;
    v += (n.x >= 0)? 1: 0;

+ 3 - 1
Engine/source/collision/clippedPolyList.h

@@ -49,7 +49,7 @@ class ClippedPolyList : public AbstractPolyList
 public:
    struct Vertex {
       Point3F point;
-      U32 mask;
+      U32 mask = 0;
    };
 
    struct Poly {
@@ -61,6 +61,8 @@ public:
       U32 vertexCount;
       U32 surfaceKey;
 	  U32 polyFlags;
+     Poly() :object(NULL), material(NULL), vertexStart(0), vertexCount(0), surfaceKey(0), polyFlags(0) {}
+     ~Poly() {}
    };
 
    /// ???

+ 5 - 1
Engine/source/collision/collision.h

@@ -65,7 +65,11 @@ struct Collision
       object( NULL ),
       material( NULL ),
       generateTexCoord(false),
-      texCoord(-1.0f, -1.0f)
+      texCoord(-1.0f, -1.0f),
+      face(0),
+      faceDot(-1.0f),
+      distance(FLT_MAX)
+
    {
    }
 };

+ 3 - 0
Engine/source/collision/concretePolyList.h

@@ -48,6 +48,9 @@ class ConcretePolyList : public AbstractPolyList
 
       Poly()
       {
+         vertexStart = 0;
+         vertexCount = 0;
+         surfaceKey = 0;
          object = NULL;
          material = NULL;
       }

+ 11 - 6
Engine/source/collision/convex.cpp

@@ -52,7 +52,9 @@ F32 sqrDistanceEdges(const Point3F& start0,
 
 CollisionState::CollisionState()
 {
-   mLista = mListb = 0;
+   mB = mA = NULL;
+   mDist = 0.0f;
+   mListb = mLista = 0;
 }
 
 CollisionState::~CollisionState()
@@ -85,7 +87,7 @@ F32 CollisionState::distance(const MatrixF& a2w, const MatrixF& b2w, const F32 d
 void ConvexFeature::reset()
 {
    material = NULL;
-   object = NULL;
+   mObject = NULL;
    mVertexList.clear();
    mEdgeList.clear();
    mFaceList.clear();
@@ -114,7 +116,7 @@ bool ConvexFeature::collide(ConvexFeature& cf,CollisionList* cList, F32 tol)
       {
          Collision &col = (*cList)[cList->getCount() - 1];
          col.material = cf.material;
-         col.object   = cf.object;
+         col.object   = cf.mObject;
       }
       vert++;
    }
@@ -167,7 +169,7 @@ void ConvexFeature::testVertex(const Point3F& v,CollisionList* cList,bool flip,
          if (flip)
             info.normal.neg();
          info.material = material;
-         info.object = object;
+         info.object = mObject;
          info.distance = distance;
       }
    }
@@ -213,7 +215,7 @@ void ConvexFeature::testEdge(ConvexFeature* cf,const Point3F& s1, const Point3F&
       info.normal   = normal;
       info.distance = distance;
       info.material = material;
-      info.object   = object;
+      info.object   = mObject;
    }
 }
 
@@ -282,6 +284,7 @@ CollisionWorkingList::CollisionWorkingList()
 {
    wLink.mPrev = wLink.mNext = this;
    rLink.mPrev = rLink.mNext = this;
+   mConvex = NULL;
 }
 
 void CollisionWorkingList::wLinkAfter(CollisionWorkingList* ptr)
@@ -340,6 +343,8 @@ Convex::Convex()
 {
    mNext = mPrev = this;
    mTag = 0;
+   mObject = NULL;
+   mType = ConvexType::BoxConvexType;
 }
 
 Convex::~Convex()
@@ -418,7 +423,7 @@ Point3F Convex::support(const VectorF&) const
 
 void Convex::getFeatures(const MatrixF&,const VectorF&,ConvexFeature* f)
 {
-   f->object = NULL;
+   f->mObject = NULL;
 }
 
 const MatrixF& Convex::getTransform() const

+ 2 - 2
Engine/source/collision/convex.h

@@ -56,10 +56,10 @@ public:
    Vector<Edge> mEdgeList;
    Vector<Face> mFaceList;
    BaseMatInstance* material;
-   SceneObject* object;
+   SceneObject* mObject;
 
    ConvexFeature()
-      : mVertexList(64), mEdgeList(128), mFaceList(64), material( 0 )
+      : mVertexList(64), mEdgeList(128), mFaceList(64), material( 0 ), mObject(NULL)
    {
       VECTOR_SET_ASSOCIATION(mVertexList);
       VECTOR_SET_ASSOCIATION(mEdgeList);

+ 7 - 0
Engine/source/collision/depthSortList.cpp

@@ -46,6 +46,13 @@ S32 gBadSpots = 0;
 
 DepthSortList::DepthSortList()
 {
+   mBase = 0;
+   mBasePoly = NULL;
+   mBaseNormal = NULL;
+   mBaseDot = 0.0f;
+   mBaseYMax = 0.0f;
+   mMaxTouched = 0;
+   mBaseExtents = NULL;
    VECTOR_SET_ASSOCIATION(mPolyExtentsList);
    VECTOR_SET_ASSOCIATION(mPolyIndexList);
 }

+ 1 - 0
Engine/source/collision/extrudedPolyList.cpp

@@ -47,6 +47,7 @@ ExtrudedPolyList::ExtrudedPolyList()
    mPolyPlaneList.reserve(64);
    mPlaneList.reserve(64);
    mCollisionList = 0;
+   dMemset(&mPoly, 0, sizeof(mPoly));
 }
 
 ExtrudedPolyList::~ExtrudedPolyList()

+ 5 - 2
Engine/source/collision/extrudedPolyList.h

@@ -56,13 +56,15 @@ class ExtrudedPolyList: public AbstractPolyList
 public:
    struct Vertex {
       Point3F point;
-      U32 mask;
+      U32 mask = 0;
    };
 
    struct Poly {
       PlaneF plane;
       SceneObject* object;
       BaseMatInstance* material;
+      Poly() : object(NULL), material(NULL) {}
+      ~Poly() {}
    };
 
    struct ExtrudedFace {
@@ -75,6 +77,8 @@ public:
       F32 time;
       Point3F point;
       F32 height;
+      ExtrudedFace(): active(false), maxDistance(0.0f), planeMask(0), faceDot(0.0f), faceShift(0.0f), time(0.0f), height(0.0f) {}
+      ~ExtrudedFace() {}
    };
 
    typedef Vector<ExtrudedFace> ExtrudedList;
@@ -92,7 +96,6 @@ public:
    PlaneList    mPlaneList;
    VectorF      mVelocity;
    VectorF      mNormalVelocity;
-   F32          mFaceShift;
    Poly         mPoly;
 
    // Returned info

+ 13 - 0
Engine/source/collision/gjk.cpp

@@ -46,6 +46,19 @@ S32 num_irregularities = 0;
 
 GjkCollisionState::GjkCollisionState()
 {
+   mBits = 0;
+   mAll_bits = 0;
+   U32 x, y;
+   for (x = 0; x < 16; x++)
+      for (y = 0; y < 4; y++)
+         mDet[x][y] = 0.0f;
+
+   for (x = 0; x < 4; x++)
+      for (y = 0; y < 4; y++)
+         mDP[x][y] = 0.0f;
+
+   mLast = 0;
+   mLast_bit = 0;
    mA = mB = 0;
 }
 

+ 2 - 0
Engine/source/collision/optimizedPolyList.h

@@ -88,7 +88,9 @@ class OptimizedPolyList : public AbstractPolyList
       Poly()
          : plane( -1 ),
            material( NULL ),
+           vertexStart(0),
            vertexCount( 0 ),
+           surfaceKey(0),
            object( NULL ),
            type( TriangleFan )
       {

+ 1 - 0
Engine/source/collision/planeExtractor.cpp

@@ -37,6 +37,7 @@ PlaneExtractorPolyList::PlaneExtractorPolyList()
 {
    VECTOR_SET_ASSOCIATION(mVertexList);
    VECTOR_SET_ASSOCIATION(mPolyPlaneList);
+   mPlaneList = NULL;
 }
 
 PlaneExtractorPolyList::~PlaneExtractorPolyList()

+ 1 - 0
Engine/source/collision/polytope.h

@@ -76,6 +76,7 @@ public:
       Collision()
       {
          object = NULL;
+         material = NULL;
          distance = 0.0;
       }
    };

+ 1 - 1
Engine/source/environment/meshRoad.cpp

@@ -309,7 +309,7 @@ Point3F MeshRoadConvex::support(const VectorF& vec) const
 void MeshRoadConvex::getFeatures(const MatrixF& mat, const VectorF& n, ConvexFeature* cf)
 {
    cf->material = 0;
-   cf->object = mObject;
+   cf->mObject = mObject;
 
    // For a tetrahedron this is pretty easy... first
    // convert everything into world space.

+ 2 - 2
Engine/source/forest/forestCollision.cpp

@@ -124,7 +124,7 @@ Point3F ForestConvex::support(const VectorF& v) const
 void ForestConvex::getFeatures( const MatrixF &mat, const VectorF &n, ConvexFeature *cf )
 {
    cf->material = 0;
-   cf->object = mObject;
+   cf->mObject = mObject;
 
    TSShapeInstance *si = mData->getShapeInstance();
 
@@ -475,4 +475,4 @@ bool ForestItem::castRay( const Point3F &start, const Point3F &end, RayInfo *out
       *(ForestItem*)(outInfo->userData) = *this;
 
    return true;   
-}
+}

+ 1 - 1
Engine/source/terrain/terrCollision.cpp

@@ -231,7 +231,7 @@ void TerrainConvex::getFeatures(const MatrixF& mat,const VectorF& n, ConvexFeatu
 {
    U32 i;
    cf->material = 0;
-   cf->object = mObject;
+   cf->mObject = mObject;
 
    // Plane is normal n + support point
    PlaneF plane;