From ec8cd95382fd4e568dcb40868bb7aade3be52de1 Mon Sep 17 00:00:00 2001 From: grisenti Date: Mon, 19 Dec 2022 22:12:43 +0100 Subject: [PATCH] HPL1: remove global variable --- engines/hpl1/engine/impl/PhysicsBodyNewton.cpp | 14 ++++++-------- engines/hpl1/engine/impl/PhysicsBodyNewton.h | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/engines/hpl1/engine/impl/PhysicsBodyNewton.cpp b/engines/hpl1/engine/impl/PhysicsBodyNewton.cpp index 265b1d22da6..f57f04e750c 100644 --- a/engines/hpl1/engine/impl/PhysicsBodyNewton.cpp +++ b/engines/hpl1/engine/impl/PhysicsBodyNewton.cpp @@ -430,14 +430,13 @@ void cPhysicsBodyNewton::OnTransformCallback(const NewtonBody *apBody, const dFl //----------------------------------------------------------------------- -// callback for buoyancy -static cPlanef gSurfacePlane; -static int BuoyancyPlaneCallback(const int alCollisionID, void *apContext, +int cPhysicsBodyNewton::BuoyancyPlaneCallback(const int alCollisionID, void *apContext, const float *afGlobalSpaceMatrix, float *afGlobalSpacePlane) { - afGlobalSpacePlane[0] = gSurfacePlane.a; - afGlobalSpacePlane[1] = gSurfacePlane.b; - afGlobalSpacePlane[2] = gSurfacePlane.c; - afGlobalSpacePlane[3] = gSurfacePlane.d; + cPlanef surfacePlane = static_cast(apContext)->mBuoyancy.mSurface; + afGlobalSpacePlane[0] = surfacePlane.a; + afGlobalSpacePlane[1] = surfacePlane.b; + afGlobalSpacePlane[2] = surfacePlane.c; + afGlobalSpacePlane[3] = surfacePlane.d; return 1; } @@ -461,7 +460,6 @@ void cPhysicsBodyNewton::OnUpdateCallback(NewtonBody *apBody, float, int) { // Create Buoyancy if (pRigidBody->mBuoyancy.mbActive) { - gSurfacePlane = pRigidBody->mBuoyancy.mSurface; VEC3_CONST_ARRAY(gravity, vGravity); NewtonBodyAddBuoyancyForce(apBody, pRigidBody->mBuoyancy.mfDensity, diff --git a/engines/hpl1/engine/impl/PhysicsBodyNewton.h b/engines/hpl1/engine/impl/PhysicsBodyNewton.h index d308aa93ab0..4100edc2b60 100644 --- a/engines/hpl1/engine/impl/PhysicsBodyNewton.h +++ b/engines/hpl1/engine/impl/PhysicsBodyNewton.h @@ -101,6 +101,8 @@ public: static void SetUseCallback(bool abX) { mbUseCallback = abX; } private: + static int BuoyancyPlaneCallback(const int alCollisionID, void *apContext, + const float *afGlobalSpaceMatrix, float *afGlobalSpacePlane); static void OnTransformCallback(const NewtonBody *apBody, const dFloat *apMatrix, int); static void OnUpdateCallback(NewtonBody *apBody, float, int);