+#include "common.h"
+
+static int ray_world( v3f pos, v3f dir, ray_hit *hit );
+
#ifndef WORLD_H
#define WORLD_H
-#define VG_3D
-#include "vg/vg.h"
-
#include "scene.h"
#include "terrain.h"
#include "render.h"
#include "water.h"
#include "rigidbody.h"
#include "gate.h"
+#include "bvh.h"
#include "shaders/standard.h"
v3f tutorial;
-#if 0
- rigidbody box;
-#endif
-
teleport_gate gates[16];
u32 gate_count;
-
+
rigidbody temp_rbs[32];
u32 rb_count;
+
+ bh_tree bhcubes;
}
world;
static int ray_world( v3f pos, v3f dir, ray_hit *hit )
{
- return bvh_raycast( &world.geo, pos, dir, hit );
+ return scene_raycast( &world.geo, pos, dir, hit );
}
static int ray_hit_is_ramp( ray_hit *hit )
}
scene_upload( &world.geo );
- bvh_create( &world.geo );
+ scene_bh_create( &world.geo );
water_compute_depth( world.geo.bbx );
*
* then compute bvh
*/
-#if 0
- scene_add_foliage( &world.foliage, mworld, boxtest, world.box.to_world );
-#endif
-
-
-#if 0
- submodel *boxtest = submodel_get( mworld, "cubey" );
-
-#endif
for( int i=0; i<mworld->layer_count; i++ )
{
rb_update_transform( rb );
}
-
free( mworld );
v3f volume;
if( ray_world( pos, (v3f){0.0f,-1.0f,0.0f}, &hit ))
{
if( hit.normal[1] > 0.8f && !ray_hit_is_ramp(&hit) &&
- hit.pos[1] > wrender.height )
+ hit.pos[1] > water_height()+10.0f )
{
v4f qsurface, qrandom;
v3f axis;
v3_copy( hit.pos, transform[3] );
- if( vg_randf() < 0.00000006f )
+ if( vg_randf() < 0.0006f )
{
m3x3_identity( transform );
scene_add_foliage( &world.foliage, mfoliage, sm_tree, transform);
free( mfoliage );
scene_upload( &world.foliage );
+
+ bh_create( &world.bhcubes,
+ &bh_system_rigidbodies, world.temp_rbs, world.rb_count );
}
#endif /* WORLD_H */