MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DoPhysLinkedFrame

Function DoPhysLinkedFrame

physics/physics.cpp:85–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83float Gravity_strength = -32.2f; // Meters/second^2
84
85void DoPhysLinkedFrame(object *obj) {
86 object *parent = ObjGet(obj->mtype.obj_link_info.parent_handle);
87 matrix new_orient;
88 vector new_pos;
89
90 if (parent && parent->type != OBJ_GHOST && parent->type != OBJ_DUMMY) {
91 poly_model *pm;
92 vector pnt;
93 vector fvec;
94 vector uvec;
95 matrix m;
96 int mn; // submodel number
97 float normalized_time[MAX_SUBOBJECTS];
98
99 pm = &Poly_models[parent->rtype.pobj_info.model_num];
100 ASSERT(pm->used);
101
102 SetNormalizedTimeObj(parent, normalized_time);
103
104 SetModelAnglesAndPos(pm, normalized_time);
105
106 pnt = obj->mtype.obj_link_info.pos;
107 fvec = obj->mtype.obj_link_info.fvec;
108 uvec = obj->mtype.obj_link_info.uvec;
109
110 mn = obj->mtype.obj_link_info.sobj_index;
111
112 if (mn < 0 || mn >= pm->n_models) {
113 mprintf(0, "Caught physics link bug!\n");
114 SetObjectDeadFlag(obj);
115 return;
116 }
117
118 // Instance up the tree for this gun
119 while (mn != -1) {
120 vector tpnt;
121
122 vm_AnglesToMatrix(&m, pm->submodel[mn].angs.p, pm->submodel[mn].angs.h, pm->submodel[mn].angs.b);
123 vm_TransposeMatrix(&m);
124
125 tpnt = pnt * m;
126 fvec = fvec * m;
127 uvec = uvec * m;
128
129 pnt = tpnt + pm->submodel[mn].offset + pm->submodel[mn].mod_pos;
130
131 mn = pm->submodel[mn].parent;
132 }
133
134 // now instance for the entire object
135 m = parent->orient;
136 vm_TransposeMatrix(&m);
137
138 new_pos = pnt * m;
139 fvec = fvec * m;
140 uvec = uvec * m;
141
142 vm_VectorToMatrix(&new_orient, &fvec, &uvec, NULL);

Callers 1

ObjDoFrameAllFunction · 0.85

Calls 8

ObjGetFunction · 0.85
SetNormalizedTimeObjFunction · 0.85
SetModelAnglesAndPosFunction · 0.85
SetObjectDeadFlagFunction · 0.85
ObjSetPosFunction · 0.85
vm_AnglesToMatrixFunction · 0.50
vm_TransposeMatrixFunction · 0.50
vm_VectorToMatrixFunction · 0.50

Tested by

no test coverage detected