~mulder-nebulon/openracing/cleaned

« back to all changes in this revision

Viewing changes to src/libsimulator/simuv2/collide.cpp

  • Committer: Nagy Imre
  • Date: 2009-04-04 06:54:16 UTC
  • Revision ID: mulder@codenode-20090404065416-ybb5akhb6im7b0x6
Almost ok, but in Z-180, it rotates backwards

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
        tWheel *wheel;
31
31
        const float CRASH_THRESHOLD = -5.0f;
32
32
 
33
 
        if (car->carElt->_state & RM_CAR_STATE_NO_SIMU) {
 
33
        if (car->carElt->_state & RM_CAR_STATE_NO_SIMU) 
 
34
            {
34
35
                return;
35
 
        }
 
36
            }
36
37
 
37
 
        for (i = 0; i < 4; i++) {
 
38
        for (i = 0; i < 4; i++) 
 
39
            {
38
40
                wheel = &(car->wheel[i]);
39
41
                tWheelState *wheelState = &(car->carElt->priv.wheel[i]);
40
 
                if (wheel->state & SIM_SUSP_COMP) {
 
42
                if (wheel->state & SIM_SUSP_COMP) 
 
43
                    {
41
44
                        car->DynGCg.pos.z += wheel->susp.spring.packers - wheel->rideHeight;
42
 
//IMRE: here, we fetch the normal, surface rebound (should be injected from ODE)
43
 
// now we overdrive the values
44
 
//TODO: make the normals come from the Ogre mesh normals
45
 
 
46
 
                        // RtTrackSurfaceNormalL(&(wheel->trkPos), &normal);
47
45
                        
48
46
                        normal.x =  wheelState->nnorm_x;
49
 
                        normal.y =  wheelState->nnorm_z;
50
 
                        normal.z = -wheelState->nnorm_y;
 
47
                        normal.y =  wheelState->nnorm_y;
 
48
                        normal.z =  wheelState->nnorm_z;
 
49
                        
 
50
                        normal.x = 0.0f;
 
51
                        normal.y = 0.0f;
 
52
                        normal.z = 1.0f;
 
53
 
51
54
                        float kRebound = 1.2000f;
52
55
                        float kDammage = 0.0000f;
53
56
                        
54
57
                        dotProd = (car->DynGCg.vel.x * normal.x + car->DynGCg.vel.y * normal.y + car->DynGCg.vel.z * normal.z) * kRebound;
55
 
                        if (dotProd < 0) {
56
 
                                if (dotProd < CRASH_THRESHOLD) {
 
58
                        if (dotProd < 0) 
 
59
                            {
 
60
                                if (dotProd < CRASH_THRESHOLD) 
 
61
                                    {
57
62
                                        car->collision |= SEM_COLLISION_Z_CRASH;
58
 
                                }
 
63
                                    }
59
64
                                car->collision |= SEM_COLLISION | SEM_COLLISION_Z;
60
65
                                car->DynGCg.vel.x -= normal.x * dotProd;
61
66
                                car->DynGCg.vel.y -= normal.y * dotProd;
62
67
                                car->DynGCg.vel.z -= normal.z * dotProd;
63
 
                                if ((car->carElt->_state & RM_CAR_STATE_FINISH) == 0) {
 
68
                                if ((car->carElt->_state & RM_CAR_STATE_FINISH) == 0) 
 
69
                                    {
64
70
                                        car->dammage += (int)(kDammage * fabs(dotProd) * simDammageFactor[car->carElt->_skillLevel]);
65
 
                                }
66
 
                        }
67
 
                }
68
 
        }
 
71
                                    }
 
72
                            }
 
73
                    }
 
74
            }
69
75
}
70
76
 
71
77
const tdble BorderFriction = 0.00;
172
178
 
173
179
static void SimCarCollideResponse(void * /*dummy*/, DtObjectRef obj1, DtObjectRef obj2, const DtCollData *collData)
174
180
{
 
181
    printf("SCCR called\n");
 
182
    exit(0);
175
183
        sgVec2 n;               // Collision normal delivered by solid: Global(point1) - Global(point2)
176
184
        tCar *car[2];   // The cars.
177
185
        sgVec2 p[2];    // Collision points delivered by solid, in body local coordinates.
720
728
void
721
729
SimCarCollideCars(tSituation *s)
722
730
{
 
731
    printf("SCCC called\n");
 
732
    exit(0);
723
733
        tCar *car;
724
734
        tCarElt *carElt;
725
735
        int i;