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

Function CollideSubmodelFacesUnsorted

physics/newstyle_fi.cpp:147–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145// bm - the bitmap handle if texturing. ignored if flat shading
146
147static void CollideSubmodelFacesUnsorted(poly_model *pm, bsp_info *sm) {
148 int i;
149 int j;
150 vector colp;
151 vector newp;
152 float col_dist; // distance to hit point
153 vector *vertex_list[32];
154 vector wall_norm;
155 int face_hit_type;
156
157 // (For this reference frame)
158 ns_compute_movement_AABB();
159
160 if (ns_movement_manual_AABB(&sm->min, &sm->max)) {
161
162 for (i = 0; i < sm->num_faces; i++) {
163 if (ns_movement_manual_AABB(&sm->face_min[i], &sm->face_max[i])) {
164 polyface *fp = &sm->faces[i];
165
166 if ((GameTextures[pm->textures[fp->texnum]].flags & (TF_FLY_THRU | TF_PASS_THRU)) == 0) {
167 ASSERT(fp->nverts <= 32);
168
169 for (j = 0; j < fp->nverts; j++) {
170 vertex_list[j] = &sm->verts[fp->vertnums[j]];
171 }
172
173 face_hit_type = check_line_to_face(&newp, &colp, &col_dist, &wall_norm, fvi_query_ptr->p0, fvi_query_ptr->p1,
174 &fp->normal, vertex_list, fp->nverts, fvi_query_ptr->rad);
175 if ((fvi_query_ptr->flags & FQ_OBJ_BACKFACE) && (!face_hit_type)) {
176 vector face_normal = fp->normal;
177 int count;
178
179 face_normal *= -1.0f;
180 for (count = 0; count < fp->nverts; count++) {
181 vertex_list[fp->nverts - count - 1] = &sm->verts[fp->vertnums[count]];
182 }
183
184 face_hit_type =
185 check_line_to_face(&newp, &colp, &col_dist, &wall_norm, fvi_query_ptr->p0, fvi_query_ptr->p1,
186 &face_normal, vertex_list, fp->nverts, fvi_query_ptr->rad);
187 }
188
189 if (face_hit_type) {
190 if (col_dist < fvi_collision_dist) {
191 vector x;
192
193 fvi_check_param = true;
194 x = *fvi_query_ptr->p1 - *fvi_query_ptr->p0;
195 vm_NormalizeVector(&x);
196
197 fvi_hit_param = (newp - *fvi_query_ptr->p0) * x;
198
199 if (!(fvi_hit_param > -10000000.0 && fvi_hit_param < 10000000.0)) {
200 mprintf(0, "FVI Warning: fvi_hit_param seems yucky!\n");
201 }
202
203 fvi_collision_dist = col_dist;
204 fvi_hit_data_ptr->num_hits = 1;

Callers 1

CollideSubmodelFunction · 0.85

Calls 4

ns_compute_movement_AABBFunction · 0.85
ns_movement_manual_AABBFunction · 0.85
check_line_to_faceFunction · 0.85
vm_NormalizeVectorFunction · 0.85

Tested by

no test coverage detected