[go: up one dir, main page]

Skip to content

Commit

Permalink
daEditorX: restored carCamera for Bullet phys
Browse files Browse the repository at this point in the history
  • Loading branch information
NicSavichev committed Jan 31, 2024
1 parent 3a8d1e6 commit 2153de4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 11 additions & 2 deletions prog/tools/sceneTools/daEditorX/services/carCamera/car_phys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,20 @@ extern bool phys_bullet_get_phys_tm(int body_id, TMatrix &phys_tm, bool &obj_act
extern void phys_bullet_add_impulse(int body_ind, const Point3 &pos, const Point3 &delta, real spring_factor, real damper_factor,
real dt);
extern bool phys_bullet_load_collision(IGenLoad &crd);
extern void phys_bullet_install_tracer(bool (*traceray)(const Point3 &p, const Point3 &d, float &mt, Point3 &out_n, int &out_pmid));


static bool needSimulate = false;
static int physType = 0;
static Ptr<PhysicsResource> simObjRes = NULL;
static float curSimDt = 0.01;

static FastRtDumpManager phys_frt;
static inline bool phys_traceray_normal(const Point3 &p, const Point3 &dir, real &t, Point3 &n, int &pmid)
{
return phys_frt.traceray(p, dir, t, pmid, n);
}


namespace carphyssimulator
{
Expand Down Expand Up @@ -144,7 +151,6 @@ bool setCollisionsToWorld(mkbindump::BinDumpSaveCB &cwr)

MemoryLoadCB crd(cwr.getRawWriter().getMem(), false);
int tag = 0;
FastRtDumpManager frt;
unsigned bindump_id = 0xFFFFFFFF;

for (;;)
Expand All @@ -156,9 +162,10 @@ bool setCollisionsToWorld(mkbindump::BinDumpSaveCB &cwr)
{
case _MAKE4C('FRT'):
{
int id = frt.loadRtDump(crd, bindump_id);
int id = phys_frt.loadRtDump(crd, bindump_id);
if (id == -1)
break;
phys_bullet_install_tracer(&phys_traceray_normal);
}
break;

Expand Down Expand Up @@ -255,6 +262,8 @@ void end()

needSimulate = false;

phys_bullet_install_tracer(nullptr);
phys_frt.delAllRtDumps();
phys_bullet_close();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#define USE_BULLET_PHYSICS 1
#include <phys/dag_physics.h>
#include <phys/dag_physObject.h>
#include <phys/dag_vehicle.h>
#include <vehiclePhys/physCar.h>
#undef USE_BULLET_PHYSICS

#include "phys.inc.cpp"
Expand Down Expand Up @@ -30,3 +32,8 @@ void phys_bullet_add_impulse(int body_ind, const Point3 &pos, const Point3 &delt
}

bool phys_bullet_load_collision(IGenLoad &crd) { return pw ? pw->loadSceneCollision(crd, 0) : false; }

void phys_bullet_install_tracer(bool (*traceray)(const Point3 &p, const Point3 &d, float &mt, Point3 &out_n, int &out_pmid))
{
IPhysVehicle::bulletSetStaticTracer(traceray);
}

0 comments on commit 2153de4

Please sign in to comment.