dungeon_crawler

diff prototype/src/mesh.cc @ 71:e198e94435c8

- fixed the mesh bounding volume calculation to take transformations into account - [data] increased the light radii in deftile-lights.obj
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 16 Oct 2012 04:08:35 +0300
parents 6a471c87f9ca
children
line diff
     1.1 --- a/prototype/src/mesh.cc	Tue Oct 09 02:54:01 2012 +0300
     1.2 +++ b/prototype/src/mesh.cc	Tue Oct 16 04:08:35 2012 +0300
     1.3 @@ -107,6 +107,7 @@
     1.4  void Mesh::set_xform(const Matrix4x4 &mat)
     1.5  {
     1.6  	xform = mat;
     1.7 +	bsph_valid = false;
     1.8  }
     1.9  
    1.10  const Matrix4x4 &Mesh::get_xform() const
    1.11 @@ -234,15 +235,17 @@
    1.12  	bsph_center = Vector3(0, 0, 0);
    1.13  
    1.14  	for(unsigned int i=0; i<nverts; i++) {
    1.15 -		bsph_center += varr[i];
    1.16 +		bsph_center += varr[i].transformed(xform);
    1.17  	}
    1.18  	bsph_center /= (float)nverts;
    1.19  
    1.20 -	// assume all vertices are equidistant from the center
    1.21 -	bsph_rad = (varr[0] - bsph_center).length();
    1.22 +	// XXX assume all vertices are equidistant from the center
    1.23 +	bsph_rad = (varr[0].transformed(xform) - bsph_center).length();
    1.24  
    1.25  	glUnmapBuffer(GL_ARRAY_BUFFER);
    1.26  	bsph_valid = true;
    1.27 +
    1.28 +	printf("calculated center: %f %f %f, rad: %f\n", bsph_center.x, bsph_center.y, bsph_center.z, bsph_rad);
    1.29  }
    1.30  
    1.31  const Vector3 &Mesh::get_bsph_center() const