internal Sector( PhysicsEngine pe, VoxelWorld world, VoxelSector sector ) { this.sector = sector; content = new VoxelShape[sector.Size_x * sector.Size_y * sector.Size_z]; shape = new VoxelGridShape( content, world.VoxelBlockSize ); grid = new VoxelGrid( shape, new Vector3( sector.Pos_x * sector.Size_x * world.VoxelBlockSize , sector.Pos_y * sector.Size_y * world.VoxelBlockSize , sector.Pos_z * sector.Size_z * world.VoxelBlockSize ) ); PhysicsSpace = pe.world; }
public static void DrawSpace( Display render, PhysicsEngine engine ) { if( engine != null ) { geometry.Clear(); foreach( Entity e in engine.test_entitites ) { Box box = e as Box; DrawBox( render, box ); } lock( engine.active_sectors ) { //if( false ) foreach( PhysicsEngine.Sector s in engine.active_sectors ) { int n = 0; if( s.Empty ) continue; if( false ) foreach( VoxelShape shp in s.content ) { if( shp != VoxelShape.Empty ) { int x = (int)(( n / s.sector.Size_y ) % s.sector.Size_x); int y = (int)( n % s.sector.Size_y); int z = (int)( ( n / ( s.sector.Size_x * s.sector.Size_y ) ) % s.sector.Size_z ); BoundingBox bb; //Log.log( "found non empty at sector {0} {1} {2} offset {3}" // , s.sector.Pos_x, s.sector.Pos_y, s.sector.Pos_z // , n ); bb.Min.X = s.sector.Pos_x * 32 + x; bb.Min.Y = s.sector.Pos_y * 32 + y; bb.Min.Z = s.sector.Pos_z * 32 + z; bb.Max.X = bb.Min.X + 1; bb.Max.Y = bb.Min.Y + 1; bb.Max.Z = bb.Min.Z + 1; DrawBoundingBox( render, bb ); //if( n > 2000 ) // break; } n++; } DrawBoundingBox( render, s.grid.BoundingBox ); } } geometry.DrawBuffer( PrimitiveType.Lines ); } }