Subversion Repositories Games.Carmageddon

Rev

Rev 1 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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