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 "oil.h" |
1 | #include "oil.h" |
2 | #include "brender.h" |
2 | #include "brender/brender.h" |
3 | #include "finteray.h" |
3 | #include "finteray.h" |
4 | #include "globvars.h" |
4 | #include "globvars.h" |
5 | #include "globvrpb.h" |
5 | #include "globvrpb.h" |
6 | #include "harness/trace.h" |
6 | #include "harness/trace.h" |
7 | #include "loading.h" |
7 | #include "loading.h" |
Line 39... | Line 39... | ||
39 | the_material->power = 0.0f; |
39 | the_material->power = 0.0f; |
40 | the_material->index_base = 0; |
40 | the_material->index_base = 0; |
41 | the_material->flags |= BR_MATF_LIGHT; |
41 | the_material->flags |= BR_MATF_LIGHT; |
42 | the_material->flags |= BR_MATF_PERSPECTIVE; |
42 | the_material->flags |= BR_MATF_PERSPECTIVE; |
43 | the_material->flags |= BR_MATF_SMOOTH; |
43 | the_material->flags |= BR_MATF_SMOOTH; |
- | 44 | // TODO: added by dethrace, investigate why oil spills in OG do not need this flag set to render correctly |
|
- | 45 | the_material->flags |= BR_MATF_TWO_SIDED; |
|
44 | the_material->index_range = 0; |
46 | the_material->index_range = 0; |
45 | the_material->colour_map = NULL; |
47 | the_material->colour_map = NULL; |
46 | BrMatrix23Identity(&the_material->map_transform); |
48 | BrMatrix23Identity(&the_material->map_transform); |
47 | the_material->index_shade = BrTableFind("IDENTITY.TAB"); |
49 | the_material->index_shade = BrTableFind("IDENTITY.TAB"); |
48 | BrMaterialUpdate(the_material, BR_MATU_ALL); |
50 | BrMaterialUpdate(the_material, BR_MATU_ALL); |
Line 163... | Line 165... | ||
163 | BrMatrix34PreRotateY(&pOil->actor->t.t.mat, angle_to_rotate_by); |
165 | BrMatrix34PreRotateY(&pOil->actor->t.t.mat, angle_to_rotate_by); |
164 | kev_bounds.mat = &car->car_master_actor->t.t.mat; |
166 | kev_bounds.mat = &car->car_master_actor->t.t.mat; |
165 | face_count = FindFacesInBox(&kev_bounds, the_list, COUNT_OF(the_list)); |
167 | face_count = FindFacesInBox(&kev_bounds, the_list, COUNT_OF(the_list)); |
166 | BrVector3Set(&v, .0f, .2f, .0f); |
168 | BrVector3Set(&v, .0f, .2f, .0f); |
167 | BrMatrix34ApplyP(&ray_pos, &v, &car->car_master_actor->t.t.mat); |
169 | BrMatrix34ApplyP(&ray_pos, &v, &car->car_master_actor->t.t.mat); |
168 | BrVector3Set(&ray_dir, 0.f, kev_bounds.original_bounds.min.v[1] - kev_bounds.original_bounds.max.v[1], 0.f); |
170 | BrVector3Set(&ray_dir, 0.f, kev_bounds.original_bounds.min.v[1] - kev_bounds.original_bounds.max.v[1], 0.f);\ |
169 | if (face_count == 0) { |
171 | if (face_count == 0) { |
170 | return 0; |
172 | return 0; |
171 | } |
173 | } |
172 | found_one = 0; |
174 | found_one = 0; |
173 | for (i = 0; i < face_count; i++) { |
175 | for (i = 0; i < face_count; i++) { |
Line 253... | Line 255... | ||
253 | void SetInitialOilStuff(tOil_spill_info* pOil, br_model* pModel) { |
255 | void SetInitialOilStuff(tOil_spill_info* pOil, br_model* pModel) { |
254 | LOG_TRACE("(%p, %p)", pOil, pModel); |
256 | LOG_TRACE("(%p, %p)", pOil, pModel); |
255 | 257 | ||
256 | pModel->vertices[0].p.v[0] = -0.1f; |
258 | pModel->vertices[0].p.v[0] = -0.1f; |
257 | pModel->vertices[0].p.v[2] = -0.1f; |
259 | pModel->vertices[0].p.v[2] = -0.1f; |
258 | pModel->vertices[1].p.v[0] = 0.1f; |
260 | pModel->vertices[1].p.v[0] = 0.1f; |
259 | pModel->vertices[1].p.v[2] = -0.1f; |
261 | pModel->vertices[1].p.v[2] = -0.1f; |
260 | pModel->vertices[2].p.v[0] = 0.1f; |
262 | pModel->vertices[2].p.v[0] = 0.1f; |
261 | pModel->vertices[2].p.v[2] = 0.1f; |
263 | pModel->vertices[2].p.v[2] = 0.1f; |
262 | pModel->vertices[3].p.v[0] = -0.1f; |
264 | pModel->vertices[3].p.v[0] = -0.1f; |
263 | pModel->vertices[3].p.v[2] = 0.1f; |
265 | pModel->vertices[3].p.v[2] = 0.1f; |
264 | pOil->actor->render_style = BR_RSTYLE_FACES; |
266 | pOil->actor->render_style = BR_RSTYLE_FACES; |
265 | BrMaterialUpdate(pOil->actor->material, BR_MATU_ALL); |
267 | BrMaterialUpdate(pOil->actor->material, BR_MATU_ALL); |
266 | BrModelUpdate(pModel, BR_MODU_ALL); |
268 | BrModelUpdate(pModel, BR_MODU_ALL); |
267 | } |
269 | } |
268 | 270 | ||
Line 282... | Line 284... | ||
282 | for (i = 0; i < COUNT_OF(gOily_spills); i++) { |
284 | for (i = 0; i < COUNT_OF(gOily_spills); i++) { |
283 | if (gOily_spills[i].car == NULL) { |
285 | if (gOily_spills[i].car == NULL) { |
284 | gOily_spills[i].actor->render_style = BR_RSTYLE_NONE; |
286 | gOily_spills[i].actor->render_style = BR_RSTYLE_NONE; |
285 | } else { |
287 | } else { |
286 | the_model = gOily_spills[i].actor->model; |
288 | the_model = gOily_spills[i].actor->model; |
287 | if (gOily_spills[i].actor->render_style == BR_RSTYLE_NONE && |
289 | if (gOily_spills[i].actor->render_style == BR_RSTYLE_NONE && |
- | 290 | gOily_spills[i].spill_time <= time && |
|
- | 291 | fabsf(gOily_spills[i].car->v.v[0]) < .01f && |
|
- | 292 | fabsf(gOily_spills[i].car->v.v[1]) < .01f && |
|
- | 293 | fabsf(gOily_spills[i].car->v.v[2]) < .01f) { |
|
288 | if (gAction_replay_mode) { |
294 | if (gAction_replay_mode) { |
289 | SetInitialOilStuff(&gOily_spills[i], the_model); |
295 | SetInitialOilStuff(&gOily_spills[i], the_model); |
290 | } else { |
296 | } else { |
291 | if (!OKToSpillOil(&gOily_spills[i])) { |
297 | if (!OKToSpillOil(&gOily_spills[i])) { |
292 | gOily_spills[i].car = NULL; |
298 | gOily_spills[i].car = NULL; |
Line 318... | Line 324... | ||
318 | NetGuaranteedSendMessageToAllPlayers(gCurrent_net_game, message, NULL); |
324 | NetGuaranteedSendMessageToAllPlayers(gCurrent_net_game, message, NULL); |
319 | } |
325 | } |
320 | } |
326 | } |
321 | } |
327 | } |
322 | } else { |
328 | } else { |
- | 329 | if (gOily_spills[i].actor->render_style == BR_RSTYLE_FACES && |
|
323 |
|
330 | (gOily_spills[i].stop_time == 0 || time < gOily_spills[i].stop_time)) { |
324 | BrVector3Sub(&v, &gOily_spills[i].original_pos, &gOily_spills[i].car->pos); |
331 | BrVector3Sub(&v, &gOily_spills[i].original_pos, &gOily_spills[i].car->pos); |
325 | grow_amount = BrVector3LengthSquared(&v); |
332 | grow_amount = BrVector3LengthSquared(&v); |
326 | if (gOily_spills[i].stop_time != 0 || grow_amount <= 0.2f) { |
333 | if (gOily_spills[i].stop_time != 0 || grow_amount <= 0.2f) { |
327 | this_size = 0.1f + (time - gOily_spills[i].spill_time) * gOily_spills[i].grow_rate; |
334 | this_size = 0.1f + (time - gOily_spills[i].spill_time) * gOily_spills[i].grow_rate; |
328 | if (this_size >= 0.1f) { |
335 | if (this_size >= 0.1f) { |
Line 365... | Line 372... | ||
365 | } |
372 | } |
366 | } |
373 | } |
367 | 374 | ||
368 | // IDA: int __cdecl GetOilSpillCount() |
375 | // IDA: int __cdecl GetOilSpillCount() |
369 | int GetOilSpillCount(void) { |
376 | int GetOilSpillCount(void) { |
370 | // |
377 | //LOG_TRACE("()"); |
371 | 378 | ||
372 | return COUNT_OF(gOily_spills); |
379 | return COUNT_OF(gOily_spills); |
373 | } |
380 | } |
374 | 381 | ||
375 | // IDA: void __usercall GetOilSpillDetails(int pIndex@<EAX>, br_actor **pActor@<EDX>, br_scalar *pSize@<EBX>) |
382 | // IDA: void __usercall GetOilSpillDetails(int pIndex@<EAX>, br_actor **pActor@<EDX>, br_scalar *pSize@<EBX>) |
Line 382... | Line 389... | ||
382 | } else { |
389 | } else { |
383 | *pActor = NULL; |
390 | *pActor = NULL; |
384 | } |
391 | } |
385 | } |
392 | } |
386 | 393 | ||
387 | #define SQR(V) ((V) |
394 | #define SQR(V) ((V)*(V)) |
388 | 395 | ||
389 | // IDA: int __usercall PointInSpill@<EAX>(br_vector3 *pV@<EAX>, int pSpill@<EDX>) |
396 | // IDA: int __usercall PointInSpill@<EAX>(br_vector3 *pV@<EAX>, int pSpill@<EDX>) |
390 | int PointInSpill(br_vector3* pV, int pSpill) { |
397 | int PointInSpill(br_vector3* pV, int pSpill) { |
391 | LOG_TRACE("(%p, %d)", pV, pSpill); |
398 | LOG_TRACE("(%p, %d)", pV, pSpill); |
392 | 399 |