
function ENTITY_CREATE_static_mesh( params )
{
	StaticMesh =
	{
		position = clone( params.position ),
		mesh_path = params.mesh,
		
		mesh = mesh = gSGR_GetMesh( params.mesh ),
		colmesh = colmesh = gSGR_GetColMesh( params.mesh ),
		inst = mi = gSGR_Scene.createMeshInstance(),
	};
	mi.mesh = mesh;
	mi.matrix = mat4().translate_v3( params.position );
	
	colshape = Bullet_CreateBVHTriangleMeshShape( colmesh );
	rbci = Bullet_CreateRigidBodyCreationInfo();
	rbci.collisionShape = colshape;
	rbci.position = params.position;
	StaticMesh.body = Bullet_CreateRigidBody( rbci );
	gSGR_BulletWorld.addRigidBody( StaticMesh.body );
	
	function StaticMesh.serialize()
	{
		return "static_mesh", { position = this.position, mesh = this.mesh_path };
	}
	
	function StaticMesh.can_reuse( type, params, data )
	{
		return type == "static_mesh" && params.mesh == this.mesh_path;
	}
	
	function StaticMesh.unserialize( data, params )
	{
		this.position = clone( params.position );
		this.body.position = params.position;
		this.inst.matrix = mat4().translate_v3( params.position );
	}
	
	function StaticMesh.removed()
	{
		gSGR_BulletWorld.removeRigidBody( this.body );
	}
	
	return StaticMesh;
}
