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

Function GetPolyModelPointInWorld

model/polymodel.cpp:3123–3173  ·  view source on GitHub ↗

Given an object, a submodel, and a vertex number, calculates the world position of that point

Source from the content-addressed store, hash-verified

3121// Given an object, a submodel, and a vertex number, calculates the world position
3122// of that point
3123void GetPolyModelPointInWorld(vector *dest, poly_model *pm, vector *wpos, matrix *orient, int subnum, vector *pos,
3124 vector *norm) {
3125 bsp_info *sm = &pm->submodel[subnum];
3126 float normalized_time[MAX_SUBOBJECTS];
3127 int i;
3128
3129 ASSERT(!(pm->flags & PMF_NOT_RESIDENT));
3130
3131 if (!pm->new_style)
3132 return;
3133
3134 for (i = 0; i < MAX_SUBOBJECTS; i++)
3135 normalized_time[i] = 0.0;
3136
3137 SetModelAnglesAndPos(pm, normalized_time);
3138
3139 vector pnt = *pos;
3140 int mn = subnum;
3141 vector cur_norm;
3142
3143 if (norm != nullptr)
3144 cur_norm = *norm;
3145
3146 matrix m;
3147
3148 // Instance up the tree for this gun
3149 while (mn != -1) {
3150 vector tpnt;
3151
3152 vm_AnglesToMatrix(&m, pm->submodel[mn].angs.p, pm->submodel[mn].angs.h, pm->submodel[mn].angs.b);
3153 vm_TransposeMatrix(&m);
3154
3155 tpnt = pnt * m;
3156
3157 if (norm != nullptr)
3158 cur_norm = cur_norm * m;
3159
3160 pnt = tpnt + pm->submodel[mn].offset + pm->submodel[mn].mod_pos;
3161
3162 mn = pm->submodel[mn].parent;
3163 }
3164
3165 // now instance for the entire object
3166 m = *orient;
3167 vm_TransposeMatrix(&m);
3168
3169 if (norm != nullptr)
3170 *norm = (cur_norm * m);
3171 *dest = pnt * m;
3172 *dest += (*wpos);
3173}
3174
3175void GetPolyModelPointInWorld(vector *dest, poly_model *pm, vector *wpos, matrix *orient, int subnum,
3176 float *normalized_time, vector *pos, vector *norm) {

Callers 5

DoDyingFrameFunction · 0.85
RotateMonitorPositionFunction · 0.85
DoNewPlayerDeathFrameFunction · 0.85
VisEffectMoveOneFunction · 0.85

Calls 3

SetModelAnglesAndPosFunction · 0.85
vm_AnglesToMatrixFunction · 0.50
vm_TransposeMatrixFunction · 0.50

Tested by

no test coverage detected