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

Method addMesh

Engine/source/ts/tsShapeEdit.cpp:959–1058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

957}
958
959bool TSShape::addMesh(TSMesh* mesh, const String& meshName)
960{
961 // Ensure mesh is in editable state
962 mesh->makeEditable();
963
964 // Need to make everything editable since node indexes etc will change
965 makeEditable();
966
967 // Determine the object name and detail size from the mesh name
968 S32 detailSize = 999;
969 String objName(String::GetTrailingNumber(meshName, detailSize));
970
971 // Find the destination object (create one if it does not exist)
972 S32 objIndex = findObject(objName);
973 if (objIndex < 0)
974 objIndex = addObject(objName, 0);
975 AssertFatal(objIndex >= 0 && objIndex < objects.size(), "Invalid object index!");
976
977 // Determine the subshape this object belongs to
978 S32 subShapeIndex = getSubShapeForObject(objIndex);
979 AssertFatal(subShapeIndex < subShapeFirstObject.size(), "Could not find subshape for object!");
980
981 // Get the existing detail levels for the subshape
982 Vector<S32> validDetails;
983 getSubShapeDetails(subShapeIndex, validDetails);
984
985 // Determine where to add the new mesh, and whether this is a new detail
986 S32 detIndex;
987 bool newDetail = true;
988 for (detIndex = 0; detIndex < validDetails.size(); detIndex++)
989 {
990 const TSShape::Detail& det = details[validDetails[detIndex]];
991 if (detailSize >= det.size)
992 {
993 newDetail = (det.size != detailSize);
994 break;
995 }
996 }
997
998 // Insert the new detail level if required
999 if (newDetail)
1000 {
1001 // Determine a name for the detail level
1002 const char* detailName;
1003 if (dStrStartsWith(objName, "Col"))
1004 detailName = "collision";
1005 else if (dStrStartsWith(objName, "loscol"))
1006 detailName = "los";
1007 else
1008 detailName = "detail";
1009
1010 S32 index = addDetail(detailName, detailSize, subShapeIndex);
1011 details[index].objectDetailNum = detIndex;
1012 }
1013
1014 // Adding a new mesh or detail level is a bit tricky, since each
1015 // object potentially stores a different number of meshes, including
1016 // NULL meshes for higher detail levels where required.

Callers 2

tsMeshFit.cppFile · 0.80

Calls 14

dStrStartsWithFunction · 0.85
destructInPlaceFunction · 0.85
getMeshTypeMethod · 0.80
find_nextMethod · 0.80
findObjectFunction · 0.50
errorfFunction · 0.50
makeEditableMethod · 0.45
sizeMethod · 0.45
findMeshMethod · 0.45
c_strMethod · 0.45
push_backMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected