11import Jolt from 'jolt-physics' ;
22// ---------------------------------------------------------------------------------------
33import { dnaManager } from '@lib/dna/dna_manager' ;
4- import { gfx3DebugRenderer } from '@lib/gfx3/gfx3_debug_renderer' ;
54import { Gfx3Jolt } from '@lib/gfx3_physics/gfx3_physics_jolt' ;
65import { DNASystem } from '@lib/dna/dna_system' ;
76import { DNAComponent } from '@lib/dna/dna_component' ;
87import { UT } from '@lib/core/utils' ;
8+ import { drawShape } from '@lib/gfx3_physics/gfx3_physics_jolt_debug' ;
99// ---------------------------------------------------------------------------------------
1010import { EntityComponent } from './entity' ;
1111// ---------------------------------------------------------------------------------------
@@ -246,12 +246,12 @@ export class PhysicsSystem extends DNASystem {
246246 return ;
247247 }
248248
249- DRAW_SHAPE ( physics . standingShape , physics . vCharacter . GetWorldTransform ( ) ) ;
249+ drawShape ( physics . standingShape , physics . vCharacter . GetWorldTransform ( ) ) ;
250250 }
251251
252252 onAfterDraw ( ) : void {
253253 for ( const body of this . debugBodies ) {
254- DRAW_SHAPE ( body . GetShape ( ) , body . GetWorldTransform ( ) ) ;
254+ drawShape ( body . GetShape ( ) , body . GetWorldTransform ( ) ) ;
255255 }
256256 }
257257
@@ -354,43 +354,4 @@ function UNWRAP_VEC3(v: vec3): Jolt.Vec3 {
354354
355355// function UNWRAP_QUAT(q: vec4): Jolt.Quat {
356356// return new Jolt.Quat(q[0], q[1], q[2], q[3])
357- // }
358-
359- function DRAW_SHAPE ( shape : Jolt . Shape , matrix : Jolt . RMat44 ) {
360- let vertexCount = 0 ;
361- const finalVertices = [ ] ;
362-
363- // Get triangle data
364- const scale = new Gfx3Jolt . Vec3 ( 1 , 1 , 1 ) ;
365- const triContext = new Gfx3Jolt . ShapeGetTriangles ( shape , Gfx3Jolt . AABox . prototype . sBiggest ( ) , shape . GetCenterOfMass ( ) , Gfx3Jolt . Quat . prototype . sIdentity ( ) , scale ) ;
366- Gfx3Jolt . destroy ( scale ) ;
367-
368- // Get a view on the triangle data (does not make a copy)
369- const vertices = new Float32Array ( Gfx3Jolt . HEAPF32 . buffer , triContext . GetVerticesData ( ) , triContext . GetVerticesSize ( ) / Float32Array . BYTES_PER_ELEMENT ) ;
370-
371- // Now move the triangle data to a buffer and clone it so that we can free the memory from the C++ heap (which could be limited in size)
372- for ( let i = 0 ; i < vertices . length / 3 ; i += 3 ) {
373- const v0 = [ vertices [ i * 3 + 0 ] , vertices [ i * 3 + 1 ] , vertices [ i * 3 + 2 ] ] ;
374- const v1 = [ vertices [ i * 3 + 3 ] , vertices [ i * 3 + 4 ] , vertices [ i * 3 + 5 ] ] ;
375- const v2 = [ vertices [ i * 3 + 6 ] , vertices [ i * 3 + 7 ] , vertices [ i * 3 + 8 ] ] ;
376-
377- finalVertices . push ( ...v0 , 0 , 1 , 0 ) ;
378- finalVertices . push ( ...v1 , 0 , 1 , 0 ) ;
379-
380- finalVertices . push ( ...v1 , 0 , 1 , 0 ) ;
381- finalVertices . push ( ...v2 , 0 , 1 , 0 ) ;
382-
383- finalVertices . push ( ...v2 , 0 , 1 , 0 ) ;
384- finalVertices . push ( ...v0 , 0 , 1 , 0 ) ;
385- vertexCount += 6 ;
386- }
387-
388- Gfx3Jolt . destroy ( triContext ) ;
389-
390- gfx3DebugRenderer . drawVertices ( finalVertices , vertexCount , [
391- matrix . GetColumn4 ( 0 ) . GetX ( ) , matrix . GetColumn4 ( 0 ) . GetY ( ) , matrix . GetColumn4 ( 0 ) . GetZ ( ) , matrix . GetColumn4 ( 0 ) . GetW ( ) ,
392- matrix . GetColumn4 ( 1 ) . GetX ( ) , matrix . GetColumn4 ( 1 ) . GetY ( ) , matrix . GetColumn4 ( 1 ) . GetZ ( ) , matrix . GetColumn4 ( 1 ) . GetW ( ) ,
393- matrix . GetColumn4 ( 2 ) . GetX ( ) , matrix . GetColumn4 ( 2 ) . GetY ( ) , matrix . GetColumn4 ( 2 ) . GetZ ( ) , matrix . GetColumn4 ( 2 ) . GetW ( ) ,
394- matrix . GetColumn4 ( 3 ) . GetX ( ) , matrix . GetColumn4 ( 3 ) . GetY ( ) , matrix . GetColumn4 ( 3 ) . GetZ ( ) , matrix . GetColumn4 ( 3 ) . GetW ( )
395- ] ) ;
396- }
357+ // }
0 commit comments