From 9884006888d9b22b20f77dea44b86d26e6f70f86 Mon Sep 17 00:00:00 2001 From: kotofyt Date: Wed, 4 Mar 2026 00:18:56 +0200 Subject: [PATCH] working physics --- build.cpp | 1 + game/server/basemodelentity.h | 10 +- game/server/build.cpp | 5 +- game/server/game.cpp | 12 +- game/server/physicsprop.cpp | 0 game/server/physicsprop.h | 16 +++ public/iphysics.h | 21 ++-- public/physics_gen.h | 22 ---- rapier/build.cpp | 30 ++++- rapier/physics.cpp | 115 ++++++++++++++++++ rapier/physics.h | 65 ++++++++++ rapier/physics.rs | 218 +++++++++++++++++++++++++++++++--- 12 files changed, 462 insertions(+), 53 deletions(-) create mode 100644 game/server/physicsprop.cpp create mode 100644 game/server/physicsprop.h delete mode 100644 public/physics_gen.h create mode 100644 rapier/physics.h diff --git a/build.cpp b/build.cpp index 7b39967..5dd5ec1 100755 --- a/build.cpp +++ b/build.cpp @@ -30,6 +30,7 @@ DECLARE_BUILD_STAGE(install_game) filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(shadercompiler, "fs")); filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Server, "server")); filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Client, "client")); + filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(rapier, "physics")); } if ( GET_PROJECT_VALUE(config, "steam") == "true" ) { filesystem2->CopyFile(szOutputDir, EXTERNAL"steamworks/redistributable_bin/linux64/libsteam_api.so"); diff --git a/game/server/basemodelentity.h b/game/server/basemodelentity.h index 0f7c633..01d8104 100644 --- a/game/server/basemodelentity.h +++ b/game/server/basemodelentity.h @@ -2,11 +2,19 @@ #define BASE_MODEL_ENTITY_H #include "baseentity.h" +#include "iphysics.h" class CBaseModelEntity: public CBaseEntity { public: - DECLARE_CLASS(CBaseModelEntity, CBaseEntity); + DECLARE_CLASS(CBaseModelEntity, CBaseEntity); + virtual void Spawn() override; + virtual void Precache() override; + +private: + HShape m_hShape; + HCollider m_hCollider; + IPhysicsBody *m_pBody; }; #endif diff --git a/game/server/build.cpp b/game/server/build.cpp index 78594b2..57b643f 100644 --- a/game/server/build.cpp +++ b/game/server/build.cpp @@ -2,9 +2,10 @@ #include "c.h" #include "ld.h" -#define EXTERNAL "../../external/" +#define ROOT "../../" +#define EXTERNAL ROOT"external/" #define FUNNYSTDLIB EXTERNAL"funnystdlib/" -ADD_DEPENDENCY_BUILD_FILE(cfg, "../../buildcfg.cpp"); +ADD_DEPENDENCY_BUILD_FILE(cfg, ROOT"buildcfg.cpp"); ADD_DEPENDENCY_BUILD_FILE(tier0, FUNNYSTDLIB"tier0/build.cpp"); ADD_DEPENDENCY_BUILD_FILE(tier1, FUNNYSTDLIB"tier1/build.cpp"); ADD_DEPENDENCY_BUILD_FILE(tier2, FUNNYSTDLIB"tier2/build.cpp"); diff --git a/game/server/game.cpp b/game/server/game.cpp index 2f46498..a26f7d5 100644 --- a/game/server/game.cpp +++ b/game/server/game.cpp @@ -6,6 +6,7 @@ #include "inetworkserver.h" #include "netprotocol.h" #include "tier1/utlvector.h" +#include "iphysics.h" #ifdef STEAM #include "steam/isteamgameserver.h" #include "steam/steam_gameserver.h" @@ -22,6 +23,9 @@ INetworkBase *g_pClientBridge; INetworkBase *g_pPublicConnection; INetworkBase *g_pCurrentConnection; +IPhysics *g_pPhysics; +IPhysicsWorld *g_pPhysicsWorld; + class CFunnyGameBridge: public IEngineBridge { virtual void Init() override; @@ -115,8 +119,13 @@ void CFunnyGameBridge::Init() #endif m_fNetUpdateTimer = 0; + + CreateInterfaceFn fnPhysicsFactory = Sys_GetFactory("RapierPhysics"); + g_pPhysics = (IPhysics*)fnPhysicsFactory(PHYSICS_INTERFACE_VERSION, NULL); + g_pPhysicsWorld = g_pPhysics->CreateWorld(); } + void CFunnyGameBridge::Tick( float fDelta ) { @@ -183,9 +192,10 @@ void CFunnyGameBridge::Frame( float fDelta ) while (m_fNetUpdateTimer >= fTickRate) { m_fNetUpdateTimer-=fTickRate; - EntitySystem()->Think(); if (g_pCurrentConnection) { + g_pPhysicsWorld->Frame(fTickRate); + EntitySystem()->Think(); EntitySystem()->NetThink(g_pCurrentConnection); } } diff --git a/game/server/physicsprop.cpp b/game/server/physicsprop.cpp new file mode 100644 index 0000000..e69de29 diff --git a/game/server/physicsprop.h b/game/server/physicsprop.h new file mode 100644 index 0000000..6f1094e --- /dev/null +++ b/game/server/physicsprop.h @@ -0,0 +1,16 @@ +#ifndef PHYSICS_PROP_H +#define PHYSICS_PROP_H + +#include "basemodelentity.h" + +class CPhysicsProp: public CBaseModelEntity +{ +friend CBaseModelEntity; +public: + DECLARE_CLASS(CPhysicsProp, CBaseModelEntity); + virtual void Spawn() override; + virtual void EnableMovement(); + virtual void DisableMovement(); +}; + +#endif diff --git a/public/iphysics.h b/public/iphysics.h index 05252ad..67dffed 100644 --- a/public/iphysics.h +++ b/public/iphysics.h @@ -4,6 +4,7 @@ #include "tier0/platform.h" #include "trig.h" +#ifndef PHYSICS_OBJECT_DEFINED struct BallShape_t { float m_fRadius; @@ -16,16 +17,18 @@ struct CuboidShape_t float m_fExtentZ; }; -typedef void *HShape; -typedef void *HCollider; - enum EPhysicsBodyType { k_EPhysics_Static, k_EPhysics_Dynamic, k_EPhysics_KinematicPositionBased, - k_EPhysics_KinematicRotationBased, + k_EPhysics_KinematicVelocityBased, }; +#endif + +typedef void *HShape; +typedef void *HCollider; + abstract_class IPhysicsBody { @@ -38,6 +41,11 @@ public: abstract_class IPhysicsWorld { public: + virtual void Frame( float fDelta ) = 0; + + virtual IPhysicsBody *CreateRigidBody( HCollider hCollider, EPhysicsBodyType eType) = 0; + virtual void DestroyPhysicsBody( IPhysicsBody *pBody ) = 0; + virtual void SetGravity( float fGravity ) = 0; }; @@ -54,9 +62,8 @@ public: virtual IPhysicsWorld *CreateWorld() = 0; virtual void DestroyWorld( IPhysicsWorld *pWorld ) = 0; - - virtual IPhysicsBody *CreateRigidBody( HCollider hCollider, EPhysicsBodyType eType) = 0; - virtual void DestroyPhysicsBody( IPhysicsBody *pBody ) = 0; }; +#define PHYSICS_INTERFACE_VERSION "Physics001" + #endif diff --git a/public/physics_gen.h b/public/physics_gen.h deleted file mode 100644 index 357f1ae..0000000 --- a/public/physics_gen.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RAPIER_H -#define RAPIER_H - - - -typedef struct RapierShape_t RapierShape_t; - -typedef struct BallShape_t { - float m_fRadius; -} BallShape_t; - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -struct RapierShape_t *CRapierPhysics_CreateBall(struct BallShape_t ball); - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#endif /* RAPIER_H */ diff --git a/rapier/build.cpp b/rapier/build.cpp index 5aa962b..5cd5530 100644 --- a/rapier/build.cpp +++ b/rapier/build.cpp @@ -4,15 +4,20 @@ #include "tier1/utlstring.h" -CUtlString rapier_lib; +#define ROOT "../" +#define EXTERNAL ROOT"external/" +#define FUNNYSTDLIB EXTERNAL"funnystdlib/" +ADD_DEPENDENCY_BUILD_FILE(tier0, FUNNYSTDLIB"tier0/build.cpp"); +ADD_DEPENDENCY_BUILD_FILE(tier1, FUNNYSTDLIB"tier1/build.cpp"); DECLARE_BUILD_STAGE(rapier) { Target_t target = Target_t::DefaultTarget(); target.abi = TARGET_ABI_GNU; + CUtlString rapier_lib; CUtlString szTarget = target.GetTriplet(); if (CommandLine()->CheckParam("-norust")) return 0; - rapier_lib = CUtlString("rapier/target/%s/release/librapier_rtt.a",szTarget.GetString()); + rapier_lib = CUtlString("target/%s/release/librapier_rtt.a",szTarget.GetString()); V_printf("%s\n",rapier_lib.GetString()); CUtlVector cargo_args = { "build", @@ -29,10 +34,29 @@ DECLARE_BUILD_STAGE(rapier) "--crate", "rapier_rtt", "--output", - "../public/physics_gen.h", + "physics.h", }; runner->Run("cbindgen", "rapier", cbindgen_args); runner->Wait(); + CProject_t cProject = {}; + cProject.m_szName = "RapierPhysics"; + cProject.files = { + "physics.cpp", + }; + cProject.includeDirectories = { + ROOT"public", + FUNNYSTDLIB"public", + }; + cProject.bFPIC = true; + LinkProject_t linkProject = ccompiler->Compile(&cProject); + linkProject.linkType = ELINK_DYNAMIC_LIBRARY; + linkProject.objects.AppendTail({rapier_lib}); + linkProject.objects.AppendTail({GET_PROJECT_OBJECT(tier1, "tier1")}); + CUtlString sz_libRapierPhysics = linker->Link(&linkProject); + + ADD_OUTPUT_OBJECT("physics", sz_libRapierPhysics); + + return 0; }; diff --git a/rapier/physics.cpp b/rapier/physics.cpp index e69de29..9dc1ef8 100644 --- a/rapier/physics.cpp +++ b/rapier/physics.cpp @@ -0,0 +1,115 @@ +//================= Copyright kotofyt, All rights reserved ==================// +// +// Purpose: Wrap rapier bindings into C++ +// +//===========================================================================// + +#include "physics.h" +#define PHYSICS_OBJECT_DEFINED +#include "iphysics.h" +#include "tier1/interface.h" + +class CRapierPhysicsBody: public IPhysicsBody +{ +public: + virtual void SetPosition( Vector vPosition ) override + { + + CRapierPhysicsBody_SetPosition(m_pBody, vPosition.x, vPosition.y, vPosition.z); + } + + virtual void SetRotation( Quat vRotation ) override + { + + } + + virtual void SetGravityScale( float fScale ) override + { + + } + RapierPhysicsBody_t *m_pBody; + +}; +class CRapierPhysicsWorld: public IPhysicsWorld +{ +public: + virtual void Frame( float fDelta ) override + { + CRapierPhysicsWorld_Frame(m_pWorld, fDelta); + } + virtual IPhysicsBody *CreateRigidBody( HCollider hCollider, EPhysicsBodyType eType) override + { + RapierPhysicsBody_t *pBody = CRapierPhysicsWorld_CreateRigidBody(m_pWorld, (RapierCollider_t*)hCollider, eType); + if (!pBody) + return NULL; + CRapierPhysicsBody *pPhysicsBody = new CRapierPhysicsBody; + pPhysicsBody->m_pBody = pBody; + return pPhysicsBody; + } + + virtual void DestroyPhysicsBody( IPhysicsBody *pBody ) override + { + + } + + + virtual void SetGravity( float fGravity ) override + { + + } + + RapierWorld_t *m_pWorld; +}; + +class CRapierPhysics: public IPhysics +{ +public: + CRapierPhysics() + { + m_pRustHandle = CRapierPhysics_New(); + } + + virtual HShape CreateBall( BallShape_t ball ) override + { + return CRapierPhysics_CreateBall(m_pRustHandle, ball); + } + + virtual HShape CreateCube( CuboidShape_t ball ) override + { + return CRapierPhysics_CreateCube(m_pRustHandle, ball); + } + + virtual void DestroyShape( HShape hShape ) override + { + + } + + + virtual HCollider CreateCollider( HShape hShape ) override + { + return CRapierPhysics_CreateCollider(m_pRustHandle, (RapierShape_t*)hShape); + } + + + virtual IPhysicsWorld *CreateWorld() override + { + RapierWorld_t *pWorld = CRapierPhysics_CreateWorld(m_pRustHandle); + if (!pWorld) + return NULL; + + CRapierPhysicsWorld *pPhysicsWorld = new CRapierPhysicsWorld; + pPhysicsWorld->m_pWorld = pWorld; + return pPhysicsWorld; + } + + virtual void DestroyWorld( IPhysicsWorld *pWorld ) override + { + + } + + + + RapierPhysics_t *m_pRustHandle; +}; + +EXPOSE_INTERFACE(CRapierPhysics, IPhysics, PHYSICS_INTERFACE_VERSION) diff --git a/rapier/physics.h b/rapier/physics.h new file mode 100644 index 0000000..b26d9d2 --- /dev/null +++ b/rapier/physics.h @@ -0,0 +1,65 @@ +#ifndef RAPIER_H +#define RAPIER_H + + + +typedef enum EPhysicsBodyType { + k_EPhysics_Static, + k_EPhysics_Dynamic, + k_EPhysics_KinematicPositionBased, + k_EPhysics_KinematicVelocityBased, +} EPhysicsBodyType; + +typedef struct RapierCollider_t RapierCollider_t; + +typedef struct RapierPhysicsBody_t RapierPhysicsBody_t; + +typedef struct RapierPhysics_t RapierPhysics_t; + +typedef struct RapierShape_t RapierShape_t; + +typedef struct RapierWorld_t RapierWorld_t; + +typedef struct BallShape_t { + float m_fRadius; +} BallShape_t; + +typedef struct CuboidShape_t { + float m_fExtentX; + float m_fExtentY; + float m_fExtentZ; +} CuboidShape_t; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void CRapierPhysicsBody_SetPosition(struct RapierPhysicsBody_t *this_, + float fX, + float fY, + float fZ); + +struct RapierPhysicsBody_t *CRapierPhysicsWorld_CreateRigidBody(struct RapierWorld_t *this_, + struct RapierCollider_t *pCollider, + enum EPhysicsBodyType eType); + +void CRapierPhysicsWorld_Frame(struct RapierWorld_t *this_, float fDelta); + +struct RapierShape_t *CRapierPhysics_CreateBall(struct RapierPhysics_t *this_, + struct BallShape_t ball); + +struct RapierCollider_t *CRapierPhysics_CreateCollider(struct RapierPhysics_t *this_, + struct RapierShape_t *pShape); + +struct RapierShape_t *CRapierPhysics_CreateCube(struct RapierPhysics_t *this_, + struct CuboidShape_t cuboid); + +struct RapierWorld_t *CRapierPhysics_CreateWorld(struct RapierPhysics_t *this_); + +struct RapierPhysics_t *CRapierPhysics_New(void); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif /* RAPIER_H */ diff --git a/rapier/physics.rs b/rapier/physics.rs index c6546b8..ec068b4 100644 --- a/rapier/physics.rs +++ b/rapier/physics.rs @@ -1,8 +1,11 @@ +//================= Copyright kotofyt, All rights reserved ==================// +// +// Purpose: Wrapper for rapier physics +// +//===========================================================================// -/* - * Rapier bindings are defined here - */ #![allow(nonstandard_style)] +#![allow(unused)] macro_rules! V_malloc { ($t:ty, $count:expr) => { @@ -10,41 +13,222 @@ macro_rules! V_malloc { }; } -use std::ptr::{self, null}; -use std::mem::transmute; +use std::{default, ptr::{self, null}, sync::Arc}; -use parry3d::shape::{Shape, ShapeType}; -use rapier3d::geometry::Ball; +use parry3d::{glamx::vec3, shape::{Shape, ShapeType, SharedShape}}; +use rapier3d::{geometry::Ball}; +use rapier3d::prelude::*; use libc::{malloc, free}; #[repr(C)] +#[derive(Clone, Copy)] pub struct BallShape_t { m_fRadius: f32, } +#[repr(C)] +#[derive(Clone, Copy)] +pub struct CuboidShape_t +{ + m_fExtentX: f32, + m_fExtentY: f32, + m_fExtentZ: f32, +} + +#[derive(Clone)] pub struct RapierShape_t { m_eType: ShapeType, - m_shape: *mut dyn Shape, + m_pShape: *mut dyn Shape, + m_sharedShape: SharedShape, } -pub struct RapierPhysics +#[repr(C)] +pub enum EPhysicsBodyType +{ + k_EPhysics_Static, + k_EPhysics_Dynamic, + k_EPhysics_KinematicPositionBased, + k_EPhysics_KinematicVelocityBased, +} + + + +#[derive(Clone)] +pub struct RapierCollider_t +{ + m_collider: Collider, +} + + + +#[derive(Clone)] +pub struct RapierWorld_t +{ + m_colliders: ColliderSet, + m_rigidBodies: RigidBodySet, + m_islandManager: IslandManager, + m_broadPhase: DefaultBroadPhase, + m_narrowPhase: NarrowPhase, + m_impulseJointSet: ImpulseJointSet, + m_multibodyJointSet: MultibodyJointSet, + m_ccdSolver: CCDSolver, +} + +#[derive(Clone)] +pub struct RapierPhysicsBody_t +{ + m_body: RigidBody, + m_pCollider: *mut RapierCollider_t, + m_pWorld: *mut RapierWorld_t, + + m_hRigidBodyHandle: RigidBodyHandle, + m_hColliderHandle: ColliderHandle, +} + +#[derive(Clone, Copy)] +pub struct RapierPhysics_t { } +#[no_mangle] +pub unsafe extern "C" fn CRapierPhysicsBody_SetPosition( this: *mut RapierPhysicsBody_t, fX: f32, fY: f32, fZ: f32 ) +{ + let world: &mut RapierWorld_t = &mut *(*this).m_pWorld; + world.m_rigidBodies[(*this).m_hRigidBodyHandle] + .set_translation(vec3(fX, fY, fZ), true); + print!("{} {} {}\n", fX, fY, fZ); +} +#[no_mangle] +pub unsafe extern "C" fn CRapierPhysicsWorld_Frame( this: *mut RapierWorld_t, fDelta: f32 ) +{ + let gravity = vec3(0.0, -9.81, 0.0); + let mut integrationParameters = IntegrationParameters::default(); + integrationParameters.dt = fDelta; + let mut physicsPipeline = PhysicsPipeline::new(); + let physicsHooks = (); + let eventHandler = (); + physicsPipeline.step( + gravity, + &integrationParameters, + &mut (*this).m_islandManager, + &mut (*this).m_broadPhase, + &mut (*this).m_narrowPhase, + &mut (*this).m_rigidBodies, + &mut (*this).m_colliders, + &mut (*this).m_impulseJointSet, + &mut (*this).m_multibodyJointSet, + &mut (*this).m_ccdSolver, + &physicsHooks, + &eventHandler, + ); + for (h, b) in (*this).m_colliders.iter() + { + print!("{:?}\n",b.position()) + } +} -#[unsafe(no_mangle)] -pub unsafe extern "C" fn CRapierPhysics_CreateBall( ball: BallShape_t ) -> *mut RapierShape_t +#[no_mangle] +pub unsafe extern "C" fn CRapierPhysicsWorld_CreateRigidBody( + this: *mut RapierWorld_t, + pCollider: *mut RapierCollider_t, + eType: EPhysicsBodyType ) -> *mut RapierPhysicsBody_t +{ + let eRapierBodyType: RigidBodyType; + match eType + { + EPhysicsBodyType::k_EPhysics_Static => eRapierBodyType = RigidBodyType::Fixed, + EPhysicsBodyType::k_EPhysics_Dynamic => eRapierBodyType = RigidBodyType::Dynamic, + EPhysicsBodyType::k_EPhysics_KinematicPositionBased => eRapierBodyType = RigidBodyType::KinematicPositionBased, + EPhysicsBodyType::k_EPhysics_KinematicVelocityBased => eRapierBodyType = RigidBodyType::KinematicVelocityBased, + } + let pBody = V_malloc!(RapierPhysicsBody_t, 1); + std::ptr::write(&mut (*pBody).m_body, RigidBodyBuilder::new(eRapierBodyType).build()); + (*pBody).m_pCollider = pCollider; + + let hRigidBodyHandle = (*this).m_rigidBodies.insert((*pBody).m_body.clone()); + let hColliderHandle = (*this).m_colliders.insert_with_parent( + (*pCollider).m_collider.clone(), hRigidBodyHandle, &mut (*this).m_rigidBodies); + (*pBody).m_hRigidBodyHandle = hRigidBodyHandle; + (*pBody).m_hColliderHandle = hColliderHandle; + (*pBody).m_pWorld = this; + + pBody +} + +#[no_mangle] +pub unsafe extern "C" fn CRapierPhysics_New() -> *mut RapierPhysics_t +{ + let physics = RapierPhysics_t {}; + let pPhysics = V_malloc!(RapierPhysics_t, 1); + *pPhysics = physics; + pPhysics +} + +#[no_mangle] +pub unsafe extern "C" fn CRapierPhysics_CreateBall( this: *mut RapierPhysics_t, ball: BallShape_t ) -> *mut RapierShape_t { let rapierShape = Ball::new(ball.m_fRadius); - let rapierShapeMemory: *mut Ball = V_malloc!(Ball, 1); - *rapierShapeMemory = rapierShape; + let pRapierShapeMemory: *mut Ball = V_malloc!(Ball, 1); + *pRapierShapeMemory = rapierShape; - let shape: RapierShape_t = RapierShape_t { m_eType: ShapeType::Ball, m_shape: rapierShapeMemory }; - let shapeMemory: *mut RapierShape_t = V_malloc!(RapierShape_t, 1); - *shapeMemory = shape; - shapeMemory + let shape: RapierShape_t = RapierShape_t { + m_eType: ShapeType::Ball, + m_pShape: pRapierShapeMemory, + m_sharedShape: SharedShape::new(rapierShape) + }; + let pShapeMemory: *mut RapierShape_t = V_malloc!(RapierShape_t, 1); + *pShapeMemory = shape; + pShapeMemory } + +#[no_mangle] +pub unsafe extern "C" fn CRapierPhysics_CreateCube( this: *mut RapierPhysics_t, cuboid: CuboidShape_t ) -> *mut RapierShape_t +{ + let rapierShape = Cuboid::new(vec3(cuboid.m_fExtentX, cuboid.m_fExtentY, cuboid.m_fExtentZ)); + let pRapierShapeMemory: *mut Cuboid = V_malloc!(Cuboid, 1); + *pRapierShapeMemory = rapierShape; + + let shape: RapierShape_t = RapierShape_t { + m_eType: ShapeType::Cuboid, + m_pShape: pRapierShapeMemory, + m_sharedShape: SharedShape::new(rapierShape) + }; + let pShapeMemory: *mut RapierShape_t = V_malloc!(RapierShape_t, 1); + *pShapeMemory = shape; + pShapeMemory +} + +#[no_mangle] +pub unsafe extern "C" fn CRapierPhysics_CreateCollider( this: *mut RapierPhysics_t, pShape: *mut RapierShape_t ) -> *mut RapierCollider_t +{ + let pRapierShape = (*pShape).m_pShape; + let shape: &SharedShape = &(*pShape).m_sharedShape; + let rapierCollider = ColliderBuilder::new(shape.clone()).build(); + let collider = RapierCollider_t { + m_collider: rapierCollider, + }; + let pCollider = V_malloc!(RapierCollider_t, 1); + *pCollider = collider; + pCollider +} + +#[no_mangle] +pub unsafe extern "C" fn CRapierPhysics_CreateWorld( this: *mut RapierPhysics_t ) -> *mut RapierWorld_t +{ + let pWorld: *mut RapierWorld_t = V_malloc!(RapierWorld_t, 1); + let world: &mut RapierWorld_t = &mut *pWorld; + std::ptr::write(&mut (*pWorld).m_colliders, ColliderSet::new()); + std::ptr::write(&mut (*pWorld).m_rigidBodies, RigidBodySet::new()); + std::ptr::write(&mut (*pWorld).m_islandManager, IslandManager::new()); + std::ptr::write(&mut (*pWorld).m_broadPhase, DefaultBroadPhase::new()); + std::ptr::write(&mut (*pWorld).m_narrowPhase, NarrowPhase::new()); + std::ptr::write(&mut (*pWorld).m_impulseJointSet, ImpulseJointSet::new()); + std::ptr::write(&mut (*pWorld).m_multibodyJointSet, MultibodyJointSet::new()); + std::ptr::write(&mut (*pWorld).m_ccdSolver, CCDSolver::new()); + pWorld +} +