Rev 18 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 18 | Rev 20 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "finteray.h" |
1 | #include "finteray.h" |
2 | #include "brender.h" |
2 | #include "brender/brender.h" |
3 | #include "brucetrk.h" |
3 | #include "brucetrk.h" |
4 | #include "car.h" |
4 | #include "car.h" |
5 | #include "formats.h" |
- | |
6 | #include "globvars.h" |
5 | #include "globvars.h" |
7 | #include "harness/trace.h" |
6 | #include "harness/trace.h" |
8 | #include "raycast.h" |
7 | #include "raycast.h" |
9 | #include "world.h" |
8 | #include "world.h" |
10 | #include <math.h> |
9 | #include <math.h> |
Line 181... | Line 180... | ||
181 | } |
180 | } |
182 | 181 | ||
183 | // IDA: int __usercall DRModelPick2D@<EAX>(br_model *model@<EAX>, br_material *material@<EDX>, br_vector3 *ray_pos@<EBX>, br_vector3 *ray_dir@<ECX>, br_scalar t_near, br_scalar t_far, dr_modelpick2d_cbfn *callback, void *arg) |
182 | // IDA: int __usercall DRModelPick2D@<EAX>(br_model *model@<EAX>, br_material *material@<EDX>, br_vector3 *ray_pos@<EBX>, br_vector3 *ray_dir@<ECX>, br_scalar t_near, br_scalar t_far, dr_modelpick2d_cbfn *callback, void *arg) |
184 | // Suffix added to avoid duplicate symbol |
183 | // Suffix added to avoid duplicate symbol |
185 | int DRModelPick2D__finteray(br_model* model, br_material* material, br_vector3* ray_pos, br_vector3* ray_dir, br_scalar t_near, br_scalar t_far, dr_modelpick2d_cbfn* callback, void* arg) { |
184 | int DRModelPick2D__finteray(br_model* model, br_material* material, br_vector3* ray_pos, br_vector3* ray_dir, br_scalar t_near, br_scalar t_far, dr_modelpick2d_cbfn* callback, void* arg) { |
186 |
|
185 | DR_FACE* fp; |
187 | int f; |
186 | int f; |
188 | int axis_m; |
187 | int axis_m; |
189 | int axis_0; |
188 | int axis_0; |
190 | int axis_1; |
189 | int axis_1; |
191 | br_scalar t; |
190 | br_scalar t; |
192 | br_scalar n |
191 | //br_scalar n; // Pierre-Marie Baty -- unused variable |
193 | br_scalar d; |
192 | br_scalar d; |
194 | br_vector3 p; |
193 | br_vector3 p; |
195 | float u0; |
194 | float u0; |
196 | float u1; |
195 | float u1; |
197 | float u2; |
196 | float u2; |
Line 210... | Line 209... | ||
210 | int v; |
209 | int v; |
211 | int e; |
210 | int e; |
212 | int r; |
211 | int r; |
213 | br_material* this_material; |
212 | br_material* this_material; |
214 | br_scalar numerator; |
213 | br_scalar numerator; |
215 |
|
214 | //float f_numerator; // Pierre-Marie Baty -- unused variable |
216 | int group; |
215 | int group; |
217 | LOG_TRACE("(%p, %p, %p, %p, %f, %f, %p, %p)", model, material, ray_pos, ray_dir, t_near, t_far, callback, arg); |
216 | LOG_TRACE("(%p, %p, %p, %p, %f, %f, %p, %p)", model, material, ray_pos, ray_dir, t_near, t_far, callback, arg); |
218 | - | ||
219 | struct v11group* grp_ptr; |
- | |
220 | br_vector4* eqn; |
- | |
221 | 217 | ||
222 | t_near -= 0.00001f; |
218 | t_near -= 0.00001f; |
223 | t_far += 0.00001f; |
219 | t_far += 0.00001f; |
224 | for (group = 0; group < V11MODEL(model)->ngroups; group++) { |
220 | for (group = 0; group < V11MODEL(model)->ngroups; group++) { |
225 | grp_ptr = &V11MODEL(model)->groups[group]; |
- | |
226 | for (f = 0; f < V11MODEL(model)->groups[group].nfaces; f++) { |
221 | for (f = 0; f < V11MODEL(model)->groups[group].nfaces; f++) { |
227 |
|
222 | fp = &V11MODEL(model)->groups[group].faces[f]; |
228 | if (V11MODEL(model)->groups[group]. |
223 | if (V11MODEL(model)->groups[group].face_colours_material) { |
229 | this_material = V11MODEL(model)->groups[group]. |
224 | this_material = V11MODEL(model)->groups[group].face_colours_material; |
230 | } else { |
225 | } else { |
231 | this_material = material; |
226 | this_material = material; |
232 | } |
227 | } |
233 | d = |
228 | d = fp->eqn.v[1] * ray_dir->v[1] + fp->eqn.v[2] * ray_dir->v[2] + fp->eqn.v[0] * ray_dir->v[0]; |
234 | if (fabs(d) >= 0.00000023841858 && (!this_material || !this_material->identifier || *this_material->identifier != '!' || !gPling_materials) |
229 | if (fabs(d) >= 0.00000023841858 && (!this_material || !this_material->identifier || *this_material->identifier != '!' || !gPling_materials) |
235 | && (!this_material || (this_material->flags & 0x1800) != 0 || d <= 0.0)) { |
230 | && (!this_material || (this_material->flags & 0x1800) != 0 || d <= 0.0)) { |
236 | numerator = |
231 | numerator = fp->eqn.v[1] * ray_pos->v[1] |
237 | + |
232 | + fp->eqn.v[2] * ray_pos->v[2] |
238 | + |
233 | + fp->eqn.v[0] * ray_pos->v[0] |
239 | - |
234 | - fp->eqn.v[3]; |
240 | if (!BadDiv__finteray(numerator, d)) { |
235 | if (!BadDiv__finteray(numerator, d)) { |
241 | t = -(numerator / d); |
236 | t = -(numerator / d); |
242 | if (t >= t_near && t <= t_far) { |
237 | if (t >= t_near && t <= t_far) { |
243 | BrVector3Scale(&p, ray_dir, t); |
238 | BrVector3Scale(&p, ray_dir, t); |
244 | BrVector3Accumulate(&p, ray_pos); |
239 | BrVector3Accumulate(&p, ray_pos); |
245 | axis_m = fabsf( |
240 | axis_m = fabsf(fp->eqn.v[0]) < fabsf(fp->eqn.v[1]); |
246 | if (fabsf( |
241 | if (fabsf(fp->eqn.v[2]) > fabsf(fp->eqn.v[axis_m])) { |
247 | axis_m = 2; |
242 | axis_m = 2; |
248 | } |
243 | } |
249 | if (axis_m) { |
244 | if (axis_m) { |
250 | axis_0 = 0; |
245 | axis_0 = 0; |
251 | if (axis_m == 1) { |
246 | if (axis_m == 1) { |
Line 256... | Line 251... | ||
256 | } else { |
251 | } else { |
257 | axis_0 = 1; |
252 | axis_0 = 1; |
258 | axis_1 = 2; |
253 | axis_1 = 2; |
259 | } |
254 | } |
260 | 255 | ||
261 | v0 = |
256 | v0 = V11MODEL(model)->groups[group].vertices[fp->vertices[0]].p.v[axis_0]; |
262 | u0 = |
257 | u0 = V11MODEL(model)->groups[group].vertices[fp->vertices[0]].p.v[axis_1]; |
263 | v1 = |
258 | v1 = V11MODEL(model)->groups[group].vertices[fp->vertices[1]].p.v[axis_0] - v0; |
264 | u1 = |
259 | u1 = V11MODEL(model)->groups[group].vertices[fp->vertices[1]].p.v[axis_1] - u0; |
265 | v2 = |
260 | v2 = V11MODEL(model)->groups[group].vertices[fp->vertices[2]].p.v[axis_0] - v0; |
266 | u2 = |
261 | u2 = V11MODEL(model)->groups[group].vertices[fp->vertices[2]].p.v[axis_1] - u0; |
267 | 262 | ||
268 | v0i1 = p.v[axis_0] - v0; |
263 | v0i1 = p.v[axis_0] - v0; |
269 | v0i2 = p.v[axis_1] - u0; |
264 | v0i2 = p.v[axis_1] - u0; |
270 | if (fabs(v1) > 0.0000002384185791015625) { |
265 | if (fabs(v1) > 0.0000002384185791015625) { |
271 | f_n = u2 * v1 - u1 * v2; |
266 | f_n = u2 * v1 - u1 * v2; |
Line 297... | Line 292... | ||
297 | } |
292 | } |
298 | 293 | ||
299 | if (alpha >= 0.0 && beta + alpha <= 1.0) { |
294 | if (alpha >= 0.0 && beta + alpha <= 1.0) { |
300 | s_alpha = alpha; |
295 | s_alpha = alpha; |
301 | s_beta = beta; |
296 | s_beta = beta; |
- | 297 | map.v[0] = V11MODEL(model)->groups[group].vertices[fp->vertices[1]].map.v[0] * s_alpha; |
|
302 |
|
298 | map.v[1] = V11MODEL(model)->groups[group].vertices[fp->vertices[1]].map.v[1] * s_alpha; |
303 | DRVector2AccumulateScale__finteray( |
299 | DRVector2AccumulateScale__finteray( |
304 | &map, |
300 | &map, |
305 | & |
301 | &V11MODEL(model)->groups[group].vertices[fp->vertices[2]].map, |
306 | s_beta); |
302 | s_beta); |
307 | DRVector2AccumulateScale__finteray( |
303 | DRVector2AccumulateScale__finteray( |
308 | &map, |
304 | &map, |
309 | & |
305 | &V11MODEL(model)->groups[group].vertices[fp->vertices[0]].map, |
310 | 1.0 - (s_alpha + s_beta)); |
306 | 1.0 - (s_alpha + s_beta)); |
311 | v = 0; |
307 | v = 0; |
312 | e = 1; |
308 | e = 1; |
313 | if (s_alpha <= s_beta) { |
309 | if (s_alpha <= s_beta) { |
314 | if (0.5 - s_beta / 2.0 > s_alpha) { |
310 | if (0.5 - s_beta / 2.0 > s_alpha) { |
Line 367... | Line 363... | ||
367 | 363 | ||
368 | // IDA: void __usercall FindFace(br_vector3 *pPosition@<EAX>, br_vector3 *pDir@<EDX>, br_vector3 *nor@<EBX>, br_scalar *t@<ECX>, br_material **material) |
364 | // IDA: void __usercall FindFace(br_vector3 *pPosition@<EAX>, br_vector3 *pDir@<EDX>, br_vector3 *nor@<EBX>, br_scalar *t@<ECX>, br_material **material) |
369 | void FindFace(br_vector3* pPosition, br_vector3* pDir, br_vector3* nor, br_scalar* t, br_material** material) { |
365 | void FindFace(br_vector3* pPosition, br_vector3* pDir, br_vector3* nor, br_scalar* t, br_material** material) { |
370 | int group; |
366 | int group; |
371 | LOG_TRACE("(%p, %p, %p, %p, %p)", pPosition, pDir, nor, t, material); |
367 | LOG_TRACE("(%p, %p, %p, %p, %p)", pPosition, pDir, nor, t, material); |
372 | - | ||
373 | br_vector4* eqn; |
- | |
374 | 368 | ||
375 | gNearest_T = 100.0f; |
369 | gNearest_T = 100.0f; |
376 | DRSceneRayPick2D(gTrack_actor, pPosition, pDir, FindHighestCallBack__finteray); |
370 | DRSceneRayPick2D(gTrack_actor, pPosition, pDir, FindHighestCallBack__finteray); |
377 | *t = gNearest_T; |
371 | *t = gNearest_T; |
378 | if (*t < 100.0f) { |
372 | if (*t < 100.0f) { |
379 | group = gNearest_face_group; |
373 | group = gNearest_face_group; |
380 |
|
374 | nor->v[0] = V11MODEL(gNearest_model)->groups[group].faces[gNearest_face].eqn.v[0]; |
381 | nor->v[0] = eqn->v[0]; |
- | |
382 | nor->v[1] = |
375 | nor->v[1] = V11MODEL(gNearest_model)->groups[group].faces[gNearest_face].eqn.v[1]; |
383 | nor->v[2] = |
376 | nor->v[2] = V11MODEL(gNearest_model)->groups[group].faces[gNearest_face].eqn.v[2]; |
384 | *material = V11MODEL(gNearest_model)->groups[group]. |
377 | *material = V11MODEL(gNearest_model)->groups[group].face_colours_material; |
385 | } |
378 | } |
386 | } |
379 | } |
387 | 380 | ||
388 | // IDA: void __cdecl EnablePlingMaterials() |
381 | // IDA: void __cdecl EnablePlingMaterials() |
389 | void EnablePlingMaterials(void) { |
382 | void EnablePlingMaterials(void) { |
Line 427... | Line 420... | ||
427 | 420 | ||
428 | this_material = pFace->material; |
421 | this_material = pFace->material; |
429 | *rt = 100.0; |
422 | *rt = 100.0; |
430 | 423 | ||
431 | d = pFace->normal.v[1] * ray_dir->v[1] + ray_dir->v[2] * pFace->normal.v[2] + ray_dir->v[0] * pFace->normal.v[0]; |
424 | d = pFace->normal.v[1] * ray_dir->v[1] + ray_dir->v[2] * pFace->normal.v[2] + ray_dir->v[0] * pFace->normal.v[0]; |
432 | if ((this_material == NULL || (this_material->flags & (BR_MATF_TWO_SIDED | BR_MATF_ALWAYS_VISIBLE)) != 0 || d <= 0.0) |
425 | if ((this_material == NULL || (this_material->flags & (BR_MATF_TWO_SIDED | BR_MATF_ALWAYS_VISIBLE )) != 0 || d <= 0.0) |
433 | && (!this_material || !this_material->identifier || *this_material->identifier != '!' || !gPling_materials) |
426 | && (!this_material || !this_material->identifier || *this_material->identifier != '!' || !gPling_materials) |
434 | && fabs(d) >= 0.00000023841858) { |
427 | && fabs(d) >= 0.00000023841858) { |
435 | BrVector3Sub(&p, ray_pos, &pFace->v[0]); |
428 | BrVector3Sub(&p, ray_pos, &pFace->v[0]); |
436 | numerator = BrVector3Dot(&pFace->normal, &p); |
429 | numerator = BrVector3Dot(&pFace->normal, &p); |
437 | if (!BadDiv__finteray(numerator, d)) { |
430 | if (!BadDiv__finteray(numerator, d)) { |
Line 713... | Line 706... | ||
713 | return j; |
706 | return j; |
714 | } |
707 | } |
715 | 708 | ||
716 | // IDA: int __usercall FindFacesInBox2@<EAX>(tBounds *bnds@<EAX>, tFace_ref *face_list@<EDX>, int max_face@<EBX>) |
709 | // IDA: int __usercall FindFacesInBox2@<EAX>(tBounds *bnds@<EAX>, tFace_ref *face_list@<EDX>, int max_face@<EBX>) |
717 | int FindFacesInBox2(tBounds* bnds, tFace_ref* face_list, int max_face) { |
710 | int FindFacesInBox2(tBounds* bnds, tFace_ref* face_list, int max_face) { |
718 | br_vector3 a |
711 | //br_vector3 a; // Pierre-Marie Baty -- unused variable |
719 | br_vector3 b |
712 | //br_vector3 b; // Pierre-Marie Baty -- unused variable |
720 | br_vector3 c |
713 | //br_vector3 c[3]; // Pierre-Marie Baty -- unused variable |
721 |
|
714 | //int i; // Pierre-Marie Baty -- unused variable |
722 |
|
715 | //int j; // Pierre-Marie Baty -- unused variable |
723 | LOG_TRACE("(%p, %p, %d)", bnds, face_list, max_face); |
716 | LOG_TRACE("(%p, %p, %d)", bnds, face_list, max_face); |
724 | - | ||
725 | a.v[0] = (bnds->original_bounds.min.v[0] + bnds->original_bounds.max.v[0]) * .5f; |
- | |
726 | a.v[1] = (bnds->original_bounds.min.v[1] + bnds->original_bounds.max.v[1]) * .5f; |
- | |
727 | a.v[2] = (bnds->original_bounds.min.v[2] + bnds->original_bounds.max.v[2]) * .5f; |
- | |
728 | BrMatrix34ApplyP(&bnds->box_centre, &a, bnds->mat); |
- | |
729 | BrVector3Sub(&b, &bnds->original_bounds.max, &bnds->original_bounds.min); |
- | |
730 | bnds->radius = BrVector3Length(&b) / 2.f; |
- | |
731 | BrMatrix34ApplyP(&bnds->real_bounds.min, &bnds->original_bounds.min, bnds->mat); |
- | |
732 | BrVector3Copy(&bnds->real_bounds.max, &bnds->real_bounds.min); |
- | |
733 |
|
717 | NOT_IMPLEMENTED(); |
734 | BrVector3Scale(&c[i], (br_vector3*)bnds->mat->m[i], b.v[i]); |
- | |
735 | } |
- | |
736 | for (i = 0; i < 3; i++) { |
- | |
737 | bnds->real_bounds.min.v[i] += MIN(0.f, c[0].v[i]) + MIN(0.f, c[1].v[i]) + MIN(0.f, c[2].v[i]); |
- | |
738 | bnds->real_bounds.max.v[i] += MAX(0.f, c[0].v[i]) + MAX(0.f, c[1].v[i]) + MAX(0.f, c[2].v[i]); |
- | |
739 | } |
- | |
740 | return max_face - ActorBoxPick(bnds, gTrack_actor, model_unk1, material_unk1, face_list, max_face, NULL); |
- | |
741 | } |
718 | } |
742 | 719 | ||
743 | // IDA: int __usercall ActorBoxPick@<EAX>(tBounds *bnds@<EAX>, br_actor *ap@<EDX>, br_model *model@<EBX>, br_material *material@<ECX>, tFace_ref *face_list, int max_face, br_matrix34 *pMat) |
720 | // IDA: int __usercall ActorBoxPick@<EAX>(tBounds *bnds@<EAX>, br_actor *ap@<EDX>, br_model *model@<EBX>, br_material *material@<ECX>, tFace_ref *face_list, int max_face, br_matrix34 *pMat) |
744 | int ActorBoxPick(tBounds* bnds, br_actor* ap, br_model* model, br_material* material, tFace_ref* face_list, int max_face, br_matrix34* pMat) { |
721 | int ActorBoxPick(tBounds* bnds, br_actor* ap, br_model* model, br_material* material, tFace_ref* face_list, int max_face, br_matrix34* pMat) { |
745 | br_model* this_model; |
722 | br_model* this_model; |
Line 838... | Line 815... | ||
838 | int ModelPickBox(br_actor* actor, tBounds* bnds, br_model* model, br_material* model_material, tFace_ref* face_list, int max_face, br_matrix34* pMat) { |
815 | int ModelPickBox(br_actor* actor, tBounds* bnds, br_model* model, br_material* model_material, tFace_ref* face_list, int max_face, br_matrix34* pMat) { |
839 | int f; |
816 | int f; |
840 | int i; |
817 | int i; |
841 | int n; |
818 | int n; |
842 | int group; |
819 | int group; |
843 |
|
820 | DR_FACE* fp; |
844 | int v1; |
821 | int v1; |
845 | int v2; |
822 | int v2; |
846 | int v3; |
823 | int v3; |
847 | br_vector3 polygon[12]; |
824 | br_vector3 polygon[12]; |
848 | br_vector3 a; |
825 | br_vector3 a; |
849 | br_vector3 tv; |
826 | br_vector3 tv; |
850 | br_scalar t; |
827 | br_scalar t; |
851 |
|
828 | v11model* prepared; |
852 | LOG_TRACE("(%p, %p, %p, %p, %p, %d, %p)", actor, bnds, model, model_material, face_list, max_face, pMat); |
829 | LOG_TRACE("(%p, %p, %p, %p, %p, %d, %p)", actor, bnds, model, model_material, face_list, max_face, pMat); |
853 | - | ||
854 | struct v11group* grp_ptr; |
- | |
855 | 830 | ||
856 | prepared = model->prepared; |
831 | prepared = model->prepared; |
857 | if (max_face <= 0) { |
832 | if (max_face <= 0) { |
858 | return 0; |
833 | return 0; |
859 | } |
834 | } |
860 | for (group = 0; prepared->ngroups > group; group++) { |
835 | for (group = 0; prepared->ngroups > group; group++) { |
861 | grp_ptr = &prepared->groups[group]; |
- | |
862 | for (f = 0; f < prepared->groups[group].nfaces; f++) { |
836 | for (f = 0; f < prepared->groups[group].nfaces; f++) { |
863 |
|
837 | fp = &prepared->groups[group].faces[f]; |
864 | v1 = |
838 | v1 = fp->vertices[0]; |
865 |
|
839 | BrVector3Sub(&a, &prepared->groups[group].vertices[v1].p, &bnds->box_centre); |
866 | BrVector3Sub(&a, &grp_ptr->position[v1], &bnds->box_centre); |
- | |
867 |
|
840 | t = BrVector3Dot((br_vector3*)&fp->eqn, &a); |
868 | t = BrVector3Dot((br_vector3*)&grp_ptr->eqn[f], &a); |
- | |
869 | if (fabsf(t) > bnds->radius) { |
841 | if (fabsf(t) > bnds->radius) { |
870 | continue; |
842 | continue; |
871 | } |
843 | } |
872 |
|
844 | v2 = fp->vertices[1]; |
873 |
|
845 | v3 = fp->vertices[2]; |
874 | v2 = grp_ptr->vertex_numbers[f].v[1]; |
- | |
875 | v3 = grp_ptr->vertex_numbers[f].v[2]; |
- | |
876 | 846 | ||
877 | t = bnds->real_bounds.min.v[0]; |
847 | t = bnds->real_bounds.min.v[0]; |
878 | if (t > |
848 | if (t > prepared->groups[group].vertices[v1].p.v[0] |
879 | && t > |
849 | && t > prepared->groups[group].vertices[v2].p.v[0] |
880 | && t > |
850 | && t > prepared->groups[group].vertices[v3].p.v[0]) { |
881 | continue; |
851 | continue; |
882 | } |
852 | } |
883 | t = bnds->real_bounds.max.v[0]; |
853 | t = bnds->real_bounds.max.v[0]; |
884 | if (t < |
854 | if (t < prepared->groups[group].vertices[v1].p.v[0] |
885 | && t < |
855 | && t < prepared->groups[group].vertices[v2].p.v[0] |
886 | && t < |
856 | && t < prepared->groups[group].vertices[v3].p.v[0]) { |
887 | continue; |
857 | continue; |
888 | } |
858 | } |
889 | t = bnds->real_bounds.min.v[1]; |
859 | t = bnds->real_bounds.min.v[1]; |
890 | if (t > |
860 | if (t > prepared->groups[group].vertices[v1].p.v[1] |
891 | && t > |
861 | && t > prepared->groups[group].vertices[v2].p.v[1] |
892 | && t > |
862 | && t > prepared->groups[group].vertices[v3].p.v[1]) { |
893 | continue; |
863 | continue; |
894 | } |
864 | } |
895 | t = bnds->real_bounds.max.v[1]; |
865 | t = bnds->real_bounds.max.v[1]; |
896 | if (t < |
866 | if (t < prepared->groups[group].vertices[v1].p.v[1] |
897 | && t < |
867 | && t < prepared->groups[group].vertices[v2].p.v[1] |
898 | && t < |
868 | && t < prepared->groups[group].vertices[v3].p.v[1]) { |
899 | continue; |
869 | continue; |
900 | } |
870 | } |
901 | t = bnds->real_bounds.min.v[2]; |
871 | t = bnds->real_bounds.min.v[2]; |
902 | if (t > |
872 | if (t > prepared->groups[group].vertices[v1].p.v[2] |
903 | && t > |
873 | && t > prepared->groups[group].vertices[v2].p.v[2] |
904 | && t > |
874 | && t > prepared->groups[group].vertices[v3].p.v[2]) { |
905 | continue; |
875 | continue; |
906 | } |
876 | } |
907 | t = bnds->real_bounds.max.v[2]; |
877 | t = bnds->real_bounds.max.v[2]; |
908 | if (t < |
878 | if (t < prepared->groups[group].vertices[v1].p.v[2] |
909 | && t < |
879 | && t < prepared->groups[group].vertices[v2].p.v[2] |
910 | && t < |
880 | && t < prepared->groups[group].vertices[v3].p.v[2]) { |
911 | continue; |
881 | continue; |
912 | } |
882 | } |
913 | BrVector3Sub(&polygon[1], & |
883 | BrVector3Sub(&polygon[1], &prepared->groups[group].vertices[v1].p, (br_vector3*)bnds->mat->m[3]); |
914 | BrVector3Sub(&polygon[2], & |
884 | BrVector3Sub(&polygon[2], &prepared->groups[group].vertices[v2].p, (br_vector3*)bnds->mat->m[3]); |
915 | BrVector3Sub(&polygon[3], & |
885 | BrVector3Sub(&polygon[3], &prepared->groups[group].vertices[v3].p, (br_vector3*)bnds->mat->m[3]); |
916 | BrMatrix34TApplyV(&polygon[0], &polygon[1], bnds->mat); |
886 | BrMatrix34TApplyV(&polygon[0], &polygon[1], bnds->mat); |
917 | BrMatrix34TApplyV(&polygon[1], &polygon[2], bnds->mat); |
887 | BrMatrix34TApplyV(&polygon[1], &polygon[2], bnds->mat); |
918 | BrMatrix34TApplyV(&polygon[2], &polygon[3], bnds->mat); |
888 | BrMatrix34TApplyV(&polygon[2], &polygon[3], bnds->mat); |
919 | n = 3; |
889 | n = 3; |
920 | for (i = 0; i < 3; i++) { |
890 | for (i = 0; i < 3; i++) { |
Line 927... | Line 897... | ||
927 | break; |
897 | break; |
928 | } |
898 | } |
929 | } |
899 | } |
930 | if (n >= 3) { |
900 | if (n >= 3) { |
931 | if (pMat != NULL) { |
901 | if (pMat != NULL) { |
932 | BrMatrix34ApplyP(&face_list->v[0], & |
902 | BrMatrix34ApplyP(&face_list->v[0], &prepared->groups[group].vertices[v1].p, pMat); |
933 | BrMatrix34ApplyP(&face_list->v[1], & |
903 | BrMatrix34ApplyP(&face_list->v[1], &prepared->groups[group].vertices[v2].p, pMat); |
934 | BrMatrix34ApplyP(&face_list->v[2], & |
904 | BrMatrix34ApplyP(&face_list->v[2], &prepared->groups[group].vertices[v3].p, pMat); |
935 | BrVector3Copy(&tv, (br_vector3*)& |
905 | BrVector3Copy(&tv, (br_vector3*)&fp->eqn); |
936 | BrMatrix34ApplyV(&face_list->normal, &tv, pMat); |
906 | BrMatrix34ApplyV(&face_list->normal, &tv, pMat); |
937 | } else { |
907 | } else { |
938 | BrVector3Copy(&face_list->v[0], & |
908 | BrVector3Copy(&face_list->v[0], &prepared->groups[group].vertices[v1].p); |
939 | BrVector3Copy(&face_list->v[1], & |
909 | BrVector3Copy(&face_list->v[1], &prepared->groups[group].vertices[v2].p); |
940 | BrVector3Copy(&face_list->v[2], & |
910 | BrVector3Copy(&face_list->v[2], &prepared->groups[group].vertices[v3].p); |
941 | BrVector3Copy(&face_list->normal, (br_vector3*)& |
911 | BrVector3Copy(&face_list->normal, (br_vector3*)&fp->eqn); |
942 | } |
912 | } |
943 | if (prepared->groups[group]. |
913 | if (prepared->groups[group].face_colours_material != NULL) { |
944 | face_list->material = prepared->groups[group]. |
914 | face_list->material = prepared->groups[group].face_colours_material; |
945 | } else { |
915 | } else { |
946 | face_list->material = model_material; |
916 | face_list->material = model_material; |
947 | } |
917 | } |
948 | face_list->flags = 0; |
918 | face_list->flags = 0; |
949 | if (face_list->material != NULL && (face_list->material->flags & (BR_MATF_TWO_SIDED | BR_MATF_ALWAYS_VISIBLE)) == 0) { |
919 | if (face_list->material != NULL && (face_list->material->flags & (BR_MATF_TWO_SIDED | BR_MATF_ALWAYS_VISIBLE)) == 0) { |
950 | face_list->flags |= (v1 < v2) | (v2 < v3) << 1 | (v3 < v1) << 2; |
920 | face_list->flags |= (v1 < v2) | (v2 < v3) << 1 | (v3 < v1) << 2; |
951 | } |
921 | } |
952 | if (pMat != NULL) { |
922 | if (pMat != NULL) { |
953 | face_list->d = BrVector3LengthSquared(&face_list->v[0]); |
923 | face_list->d = BrVector3LengthSquared(&face_list->v[0]); |
954 | } else { |
924 | } else { |
955 | face_list->d = |
925 | face_list->d = fp->eqn.v[3]; |
956 | } |
926 | } |
957 | face_list->map[0] = & |
927 | face_list->map[0] = &prepared->groups[group].vertices[v1].map; |
958 | face_list->map[1] = & |
928 | face_list->map[1] = &prepared->groups[group].vertices[v2].map; |
959 | face_list->map[2] = & |
929 | face_list->map[2] = &prepared->groups[group].vertices[v3].map; |
960 | if (face_list->material |
930 | if (face_list->material!= NULL |
961 | && face_list->material->identifier != NULL |
931 | && face_list->material->identifier != NULL |
962 | && face_list->material->identifier[0] == '!') { |
932 | && face_list->material->identifier[0] == '!') { |
963 | gPling_face = face_list; |
933 | gPling_face = face_list; |
964 | } |
934 | } |
965 | face_list++; |
935 | face_list++; |
Line 1226... | Line 1196... | ||
1226 | return 0; |
1196 | return 0; |
1227 | } |
1197 | } |
1228 | 1198 | ||
1229 | // IDA: int __usercall CompVert@<EAX>(int v1@<EAX>, int v2@<EDX>) |
1199 | // IDA: int __usercall CompVert@<EAX>(int v1@<EAX>, int v2@<EDX>) |
1230 | int CompVert(int v1, int v2) { |
1200 | int CompVert(int v1, int v2) { |
1231 | br_vertex |
1201 | //br_vertex* vl; // Pierre-Marie Baty -- unused variable |
1232 | br_vector3 tv |
1202 | //br_vector3 tv; // Pierre-Marie Baty -- unused variable |
1233 | br_vector2 tv2 |
1203 | //br_vector2 tv2; // Pierre-Marie Baty -- unused variable |
1234 | LOG_TRACE("(%d, %d)", v1, v2); |
1204 | LOG_TRACE("(%d, %d)", v1, v2); |
1235 | - | ||
1236 | if (v1 == v2) { |
- | |
1237 |
|
1205 | NOT_IMPLEMENTED(); |
1238 | } |
- | |
1239 | vl = gSelected_model->vertices; |
- | |
1240 | BrVector3Sub(&tv, &vl[v1].p, &vl[v2].p); |
- | |
1241 | if (BrVector3LengthSquared(&tv) > 1e-5f) { |
- | |
1242 | return 0; |
- | |
1243 | } |
- | |
1244 | BrVector2Sub(&tv2, &vl[v1].map, &vl[v2].map); |
- | |
1245 | if (BrVector2LengthSquared(&tv2) > 1e-5f) { |
- | |
1246 | return 0; |
- | |
1247 | } |
- | |
1248 | return 1; |
- | |
1249 | } |
1206 | } |
1250 | 1207 | ||
1251 | // IDA: void __usercall SetFacesGroup(int pFace@<EAX>) |
1208 | // IDA: void __usercall SetFacesGroup(int pFace@<EAX>) |
1252 | void SetFacesGroup(int pFace) { |
1209 | void SetFacesGroup(int pFace) { |
1253 | //int f; // Pierre-Marie Baty -- unused variable |
1210 | //int f; // Pierre-Marie Baty -- unused variable |
Line 1269... | Line 1226... | ||
1269 | NOT_IMPLEMENTED(); |
1226 | NOT_IMPLEMENTED(); |
1270 | } |
1227 | } |
1271 | 1228 | ||
1272 | // IDA: void __usercall GetTilingLimits(br_vector2 *min@<EAX>, br_vector2 *max@<EDX>) |
1229 | // IDA: void __usercall GetTilingLimits(br_vector2 *min@<EAX>, br_vector2 *max@<EDX>) |
1273 | void GetTilingLimits(br_vector2* min, br_vector2* max) { |
1230 | void GetTilingLimits(br_vector2* min, br_vector2* max) { |
1274 |
|
1231 | //int f; // Pierre-Marie Baty -- unused variable |
1275 |
|
1232 | //int i; // Pierre-Marie Baty -- unused variable |
1276 |
|
1233 | //int j; // Pierre-Marie Baty -- unused variable |
1277 | br_vertex |
1234 | //br_vertex* verts; // Pierre-Marie Baty -- unused variable |
1278 | br_face |
1235 | //br_face* faces; // Pierre-Marie Baty -- unused variable |
1279 | LOG_TRACE("(%p, %p)", min, max); |
1236 | LOG_TRACE("(%p, %p)", min, max); |
1280 | - | ||
1281 | verts = gSelected_model->vertices; |
- | |
1282 | faces = gSelected_model->faces; |
- | |
1283 | BrVector2Set(min, 32000.f, 32000.f); |
- | |
1284 | BrVector2Set(max, -32000.f, -32000.f); |
- | |
1285 | for (f = 0; f < gSelected_model->nfaces; f++) { |
- | |
1286 | if (faces[f].material == gSub_material) { |
- | |
1287 | for (i = 0; i < 3; i++) { |
- | |
1288 | for (j = 0; j < 3; j++) { |
- | |
1289 | if (verts[faces[f].vertices[i]].map.v[j] < min->v[j]) { |
- | |
1290 | min->v[j] = verts[faces[f].vertices[i]].map.v[j]; |
- | |
1291 |
|
1237 | NOT_IMPLEMENTED(); |
1292 | if (verts[faces[f].vertices[i]].map.v[j] > max->v[j]) { |
- | |
1293 | max->v[j] = verts[faces[f].vertices[i]].map.v[j]; |
- | |
1294 | } |
- | |
1295 | } |
- | |
1296 | } |
- | |
1297 | } |
- | |
1298 | } |
- | |
1299 | } |
1238 | } |
1300 | 1239 | ||
1301 | // IDA: void __usercall Scale(int pD@<EAX>, int factor@<EDX>) |
1240 | // IDA: void __usercall Scale(int pD@<EAX>, int factor@<EDX>) |
1302 | void Scale(int pD, int factor) { |
1241 | void Scale(int pD, int factor) { |
1303 | br_vector2 min |
1242 | //br_vector2 min; // Pierre-Marie Baty -- unused variable |
1304 | br_vector2 max |
1243 | //br_vector2 max; // Pierre-Marie Baty -- unused variable |
1305 |
|
1244 | //int f; // Pierre-Marie Baty -- unused variable |
1306 |
|
1245 | //int v; // Pierre-Marie Baty -- unused variable |
1307 | br_scalar d |
1246 | //br_scalar d; // Pierre-Marie Baty -- unused variable |
1308 | br_vertex |
1247 | //br_vertex* verts; // Pierre-Marie Baty -- unused variable |
1309 | br_face |
1248 | //br_face* faces; // Pierre-Marie Baty -- unused variable |
1310 | LOG_TRACE("(%d, %d)", pD, factor); |
1249 | LOG_TRACE("(%d, %d)", pD, factor); |
1311 | - | ||
1312 | if (gSelected_model == NULL) { |
- | |
1313 | return; |
- | |
1314 | } |
- | |
1315 | if (gSelected_model->nfaces != gNfaces) { |
- | |
1316 | return; |
- | |
1317 | } |
- | |
1318 | verts = gSelected_model->vertices; |
- | |
1319 | faces = gSelected_model->faces; |
- | |
1320 | GetTilingLimits(&min, &max); |
- | |
1321 | d = max.v[pD] - min.v[pD]; |
- | |
1322 | if (d <= 0.f || factor + d <= 0.f) { |
- | |
1323 | return; |
- | |
1324 | } |
- | |
1325 | for (v = 0; v < gSelected_model->nvertices; v++) { |
- | |
1326 | for (f = 0; f < gSelected_model->nfaces; f++) { |
- | |
1327 | if (faces[f].material == gSub_material |
- | |
1328 | && (faces[f].vertices[0] == v || faces[f].vertices[1] == v || faces[f].vertices[2] == v)) { |
- | |
1329 | verts[v].map.v[pD] = (factor + d) / d * verts[v].map.v[pD]; |
- | |
1330 |
|
1250 | NOT_IMPLEMENTED(); |
1331 | } |
- | |
1332 | } |
- | |
1333 | } |
- | |
1334 | BrModelUpdate(gSelected_model, BR_MODU_ALL); |
- | |
1335 | } |
1251 | } |
1336 | 1252 | ||
1337 | // IDA: void __cdecl ScaleUpX() |
1253 | // IDA: void __cdecl ScaleUpX() |
1338 | void ScaleUpX(void) { |
1254 | void ScaleUpX(void) { |
1339 | LOG_TRACE("()"); |
1255 | LOG_TRACE("()"); |
1340 | - | ||
1341 |
|
1256 | NOT_IMPLEMENTED(); |
1342 | } |
1257 | } |
1343 | 1258 | ||
1344 | // IDA: void __cdecl ScaleDnX() |
1259 | // IDA: void __cdecl ScaleDnX() |
1345 | void ScaleDnX(void) { |
1260 | void ScaleDnX(void) { |
1346 | LOG_TRACE("()"); |
1261 | LOG_TRACE("()"); |
1347 | - | ||
1348 |
|
1262 | NOT_IMPLEMENTED(); |
1349 | } |
1263 | } |
1350 | 1264 | ||
1351 | // IDA: void __cdecl ScaleUpY() |
1265 | // IDA: void __cdecl ScaleUpY() |
1352 | void ScaleUpY(void) { |
1266 | void ScaleUpY(void) { |
1353 | LOG_TRACE("()"); |
1267 | LOG_TRACE("()"); |
1354 | - | ||
1355 |
|
1268 | NOT_IMPLEMENTED(); |
1356 | } |
1269 | } |
1357 | 1270 | ||
1358 | // IDA: void __cdecl ScaleDnY() |
1271 | // IDA: void __cdecl ScaleDnY() |
1359 | void ScaleDnY(void) { |
1272 | void ScaleDnY(void) { |
1360 | LOG_TRACE("()"); |
1273 | LOG_TRACE("()"); |
1361 | - | ||
1362 |
|
1274 | NOT_IMPLEMENTED(); |
1363 | } |
1275 | } |
1364 | 1276 | ||
1365 | // IDA: void __cdecl SelectFaceForward() |
1277 | // IDA: void __cdecl SelectFaceForward() |
1366 | void SelectFaceForward(void) { |
1278 | void SelectFaceForward(void) { |
1367 | br_vector3 dir |
1279 | //br_vector3 dir; // Pierre-Marie Baty -- unused variable |
1368 | LOG_TRACE("()"); |
1280 | LOG_TRACE("()"); |
1369 | - | ||
1370 | BrVector3Scale(&dir, (br_vector3*)&gProgram_state.current_car.car_master_actor->t.t.mat.m[2], -2.f); |
- | |
1371 |
|
1281 | NOT_IMPLEMENTED(); |
1372 | } |
1282 | } |
1373 | 1283 | ||
1374 | // IDA: void __cdecl SelectFaceDown() |
1284 | // IDA: void __cdecl SelectFaceDown() |
1375 | void SelectFaceDown(void) { |
1285 | void SelectFaceDown(void) { |
1376 | br_vector3 dir |
1286 | //br_vector3 dir; // Pierre-Marie Baty -- unused variable |
1377 | LOG_TRACE("()"); |
1287 | LOG_TRACE("()"); |
1378 | - | ||
1379 | BrVector3Scale(&dir, (br_vector3*)&gProgram_state.current_car.car_master_actor->t.t.look_up.up, -2.f); |
- | |
1380 |
|
1288 | NOT_IMPLEMENTED(); |
1381 | } |
1289 | } |