improve rendering and physics
This commit is contained in:
@@ -17,10 +17,10 @@ DECLARE_BUILD_STAGE(rapier)
|
||||
CUtlString szTarget = target.GetTriplet();
|
||||
if (CommandLine()->CheckParam("-norust"))
|
||||
return 0;
|
||||
rapier_lib = CUtlString("target/%s/debug/librapier_rtt.a",szTarget.GetString());
|
||||
V_printf("%s\n",rapier_lib.GetString());
|
||||
rapier_lib = CUtlString("target/%s/release/librapier_rtt.a",szTarget.GetString());
|
||||
CUtlVector<CUtlString> cargo_args = {
|
||||
"build",
|
||||
"--release",
|
||||
"--target",
|
||||
szTarget
|
||||
};
|
||||
|
||||
@@ -42,6 +42,11 @@ public:
|
||||
return CRapierPhysicsBody_GetRotation(m_pBody);
|
||||
}
|
||||
|
||||
virtual void SetType( EPhysicsBodyType eType ) override
|
||||
{
|
||||
CRapierPhysicsBody_SetType(m_pBody, eType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RapierPhysicsBody_t *m_pBody = NULL;
|
||||
|
||||
@@ -16,7 +16,7 @@ macro_rules! V_malloc {
|
||||
use std::{default, ops::Index, ptr::{self, null, null_mut}, slice::from_raw_parts, sync::Arc};
|
||||
|
||||
use parry3d::{glamx::vec3, shape::{Shape, ShapeType, SharedShape}};
|
||||
use rapier3d::{geometry::Ball, na::{UnitQuaternion, Vector4}};
|
||||
use rapier3d::{geometry::Ball, na::{UnitQuaternion, Vector4, coordinates::XYZ}};
|
||||
use rapier3d::prelude::*;
|
||||
use libc::{malloc, free};
|
||||
|
||||
@@ -56,6 +56,7 @@ pub struct RapierShape_t
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub enum EPhysicsBodyType
|
||||
{
|
||||
k_EPhysics_Static,
|
||||
@@ -119,7 +120,8 @@ pub unsafe extern "C" fn CRapierPhysicsBody_SetRotation( this: *mut RapierPhysic
|
||||
{
|
||||
let world: &mut RapierWorld_t = &mut *(*this).m_pWorld;
|
||||
world.m_rigidBodies[(*this).m_hRigidBodyHandle]
|
||||
.set_translation(vec3(fX, fY, fZ), true);
|
||||
.set_rotation(parry3d::glamx::Quat::from_xyzw(fX, fY, fZ, fW), true);
|
||||
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@@ -256,7 +258,7 @@ pub unsafe extern "C" fn CRapierPhysics_CreateCube( this: *mut RapierPhysics_t,
|
||||
pub unsafe extern "C" fn CRapierPhysics_CreateTriangleMesh( this: *mut RapierPhysics_t, triangle: TriangleMeshShape_t ) -> *mut RapierShape_t
|
||||
{
|
||||
let pShapeMemory: *mut RapierShape_t = V_malloc!(RapierShape_t, 1);
|
||||
let positions = Vec::from_raw_parts(triangle.m_pfPositions as *mut Vec3, triangle.m_nPositionCount as usize, triangle.m_nPositionCount as usize);
|
||||
let positions = Vec::from_raw_parts(triangle.m_pfPositions as *mut Vec3, (triangle.m_nPositionCount/3) as usize, (triangle.m_nPositionCount/3) as usize);
|
||||
let mut indices: Vec<[u32; 3]>;
|
||||
|
||||
if ( triangle.m_nIndiciesCount == 0 )
|
||||
@@ -265,8 +267,8 @@ pub unsafe extern "C" fn CRapierPhysics_CreateTriangleMesh( this: *mut RapierPhy
|
||||
{
|
||||
return null_mut();
|
||||
}
|
||||
indices = vec![[0,0,0]; (triangle.m_nPositionCount/3) as usize];
|
||||
for i in 0..indices.len()/3
|
||||
indices = vec![[0,0,0]; (triangle.m_nPositionCount/9) as usize];
|
||||
for i in 0..indices.len()
|
||||
{
|
||||
let u = i as u32;
|
||||
indices[i][0] = u*3;
|
||||
@@ -281,7 +283,7 @@ pub unsafe extern "C" fn CRapierPhysics_CreateTriangleMesh( this: *mut RapierPhy
|
||||
{
|
||||
return null_mut();
|
||||
}
|
||||
indices = Vec::from_raw_parts(triangle.m_puIndicies as *mut [u32; 3], triangle.m_nIndiciesCount as usize, triangle.m_nIndiciesCount as usize);
|
||||
indices = Vec::from_raw_parts(triangle.m_puIndicies as *mut [u32; 3], (triangle.m_nIndiciesCount / 3) as usize, (triangle.m_nIndiciesCount / 3) as usize);
|
||||
}
|
||||
|
||||
let mesh = TriMesh::new(positions, indices);
|
||||
@@ -291,7 +293,9 @@ pub unsafe extern "C" fn CRapierPhysics_CreateTriangleMesh( this: *mut RapierPhy
|
||||
{
|
||||
std::ptr::write(&mut (*pShapeMemory).m_sharedShape, SharedShape::new(m));
|
||||
}
|
||||
default => {}
|
||||
default => {
|
||||
return null_mut();
|
||||
}
|
||||
}
|
||||
pShapeMemory
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user