uninitialized variables-collision

This commit is contained in:
AzaezelX 2020-05-11 14:33:59 -05:00
parent 1cea8ffacb
commit e9415a0994
18 changed files with 62 additions and 20 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -56,10 +56,10 @@ public:
Vector<Edge> mEdgeList; Vector<Edge> mEdgeList;
Vector<Face> mFaceList; Vector<Face> mFaceList;
BaseMatInstance* material; BaseMatInstance* material;
SceneObject* object; SceneObject* mObject;
ConvexFeature() 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(mVertexList);
VECTOR_SET_ASSOCIATION(mEdgeList); VECTOR_SET_ASSOCIATION(mEdgeList);

View file

@ -46,6 +46,13 @@ S32 gBadSpots = 0;
DepthSortList::DepthSortList() 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(mPolyExtentsList);
VECTOR_SET_ASSOCIATION(mPolyIndexList); VECTOR_SET_ASSOCIATION(mPolyIndexList);
} }

View file

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

View file

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

View file

@ -46,6 +46,19 @@ S32 num_irregularities = 0;
GjkCollisionState::GjkCollisionState() 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; mA = mB = 0;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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