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

Method initConstraintDefs

Engine/source/afx/afxConstraint.cpp:1028–1186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026}
1027
1028void afxConstraintMgr::initConstraintDefs(Vector<afxConstraintDef>& all_defs, bool on_server, F32 scoping_dist)
1029{
1030 mInitialized = true;
1031 mOn_server = on_server;
1032
1033 if (scoping_dist > 0.0)
1034 mScoping_dist_sq = scoping_dist*scoping_dist;
1035 else
1036 {
1037 SceneManager* sg = (on_server) ? gServerSceneGraph : gClientSceneGraph;
1038 F32 vis_dist = (sg) ? sg->getVisibleDistance() : 1000.0f;
1039 mScoping_dist_sq = vis_dist*vis_dist;
1040 }
1041
1042 if (all_defs.size() < 1)
1043 return;
1044
1045 // find effect ghost constraints
1046 if (!on_server)
1047 {
1048 Vector<afxConstraintDef> ghost_defs;
1049
1050 for (S32 i = 0; i < all_defs.size(); i++)
1051 if (all_defs[i].mDef_type == afxConstraintDef::CONS_GHOST && all_defs[i].mCons_src_name != ST_NULLSTRING)
1052 ghost_defs.push_back(all_defs[i]);
1053
1054 if (ghost_defs.size() > 0)
1055 {
1056 // sort the defs
1057 if (ghost_defs.size() > 1)
1058 dQsort(ghost_defs.address(), ghost_defs.size(), sizeof(afxConstraintDef), cmp_cons_defs);
1059
1060 S32 last = 0;
1061 defineConstraint(OBJECT_CONSTRAINT, ghost_defs[0].mCons_src_name);
1062
1063 for (S32 i = 1; i < ghost_defs.size(); i++)
1064 {
1065 if (ghost_defs[last].mCons_src_name != ghost_defs[i].mCons_src_name)
1066 {
1067 defineConstraint(OBJECT_CONSTRAINT, ghost_defs[i].mCons_src_name);
1068 last++;
1069 }
1070 }
1071 }
1072 }
1073
1074 Vector<afxConstraintDef> defs;
1075
1076 // collect defs that run here (server or client)
1077 if (on_server)
1078 {
1079 for (S32 i = 0; i < all_defs.size(); i++)
1080 if (all_defs[i].mRuns_on_server)
1081 defs.push_back(all_defs[i]);
1082 }
1083 else
1084 {
1085 for (S32 i = 0; i < all_defs.size(); i++)

Callers 3

init_constraintsMethod · 0.80
init_constraintsMethod · 0.80
init_constraintsMethod · 0.80

Calls 7

dQsortFunction · 0.85
getVisibleDistanceMethod · 0.80
isArbitraryObjectMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
addressMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected