Given an object, a submodel, and a vertex number, calculates the world position of that point
| 3121 | // Given an object, a submodel, and a vertex number, calculates the world position |
| 3122 | // of that point |
| 3123 | void 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 | |
| 3175 | void GetPolyModelPointInWorld(vector *dest, poly_model *pm, vector *wpos, matrix *orient, int subnum, |
| 3176 | float *normalized_time, vector *pos, vector *norm) { |
no test coverage detected