MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / updateBounds

Method updateBounds

Engine/source/T3D/convexShape.cpp:1014–1045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1012}
1013
1014void ConvexShape::updateBounds( bool recenter )
1015{
1016 if ( mGeometry.points.size() == 0 )
1017 return;
1018
1019 Vector<Point3F> &pointListOS = mGeometry.points;
1020 U32 pointCount = pointListOS.size();
1021
1022 Point3F volumnCenter( 0,0,0 );
1023 F32 areaSum = 0.0f;
1024
1025 F32 faceCount = mGeometry.faces.size();
1026
1027 for ( S32 i = 0; i < faceCount; i++ )
1028 {
1029 volumnCenter += mGeometry.faces[i].centroid * mGeometry.faces[i].area;
1030 areaSum += mGeometry.faces[i].area;
1031 }
1032
1033 if ( areaSum == 0.0f )
1034 return;
1035
1036 volumnCenter /= areaSum;
1037
1038 mObjBox.minExtents = mObjBox.maxExtents = Point3F::Zero;
1039 mObjBox.setCenter( volumnCenter );
1040
1041 for ( S32 i = 0; i < pointCount; i++ )
1042 mObjBox.extend( pointListOS[i] );
1043
1044 resetWorldBox();
1045}
1046
1047void ConvexShape::recenter()
1048{

Callers

nothing calls this directly

Calls 3

setCenterMethod · 0.80
extendMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected