- minor adjustments

This commit is contained in:
Magnus Norddahl 2018-11-06 23:04:29 +01:00
parent 57b39458f0
commit 639bc29085
4 changed files with 10 additions and 31 deletions

View file

@ -583,7 +583,7 @@ float TriangleMeshShape::volume(int node_index)
return extents.x * extents.y * extents.z;
}
int TriangleMeshShape::get_min_depth()
int TriangleMeshShape::get_min_depth() const
{
std::function<int(int, int)> visit;
visit = [&](int level, int node_index) -> int {
@ -596,7 +596,7 @@ int TriangleMeshShape::get_min_depth()
return visit(1, root);
}
int TriangleMeshShape::get_max_depth()
int TriangleMeshShape::get_max_depth() const
{
std::function<int(int, int)> visit;
visit = [&](int level, int node_index) -> int {
@ -609,7 +609,7 @@ int TriangleMeshShape::get_max_depth()
return visit(1, root);
}
float TriangleMeshShape::get_average_depth()
float TriangleMeshShape::get_average_depth() const
{
std::function<float(int, int)> visit;
visit = [&](int level, int node_index) -> float {
@ -624,7 +624,7 @@ float TriangleMeshShape::get_average_depth()
return depth_sum / leaf_count;
}
float TriangleMeshShape::get_balanced_depth()
float TriangleMeshShape::get_balanced_depth() const
{
return std::log2((float)(num_elements / 3));
}

View file

@ -82,10 +82,12 @@ class TriangleMeshShape
public:
TriangleMeshShape(const kexVec3 *vertices, int num_vertices, const unsigned int *elements, int num_elements, const int *surfaces);
int get_min_depth();
int get_max_depth();
float get_average_depth();
float get_balanced_depth();
int get_min_depth() const;
int get_max_depth() const;
float get_average_depth() const;
float get_balanced_depth() const;
const CollisionBBox &get_bbox() const { return nodes[root].aabb; }
static float sweep(TriangleMeshShape *shape1, SphereShape *shape2, const kexVec3 &target);

View file

@ -48,28 +48,6 @@ kexLightSurface::~kexLightSurface()
{
}
// Creates a single origin point if we're not intending on subdividing this light surface
void kexLightSurface::CreateCenterOrigin()
{
if (surface->type == ST_CEILING || surface->type == ST_FLOOR)
{
kexVec3 center;
for (int i = 0; i < surface->numVerts; ++i)
{
center += surface->verts[i];
}
origins.push_back(center / (float)surface->numVerts);
}
else
{
origins.push_back(kexVec3((surface->verts[1].x + surface->verts[0].x) * 0.5f,
(surface->verts[1].y + surface->verts[0].y) * 0.5f,
(surface->verts[2].z + surface->verts[0].z) * 0.5f));
}
}
// Splits surface vertices into two groups while adding new ones caused by the split
void kexLightSurface::Clip(vertexBatch_t &points, const kexVec3 &normal, float dist, vertexBatch_t *frontPoints, vertexBatch_t *backPoints)
{

View file

@ -39,7 +39,6 @@ public:
~kexLightSurface();
void Subdivide(const float divide);
void CreateCenterOrigin();
float TraceSurface(FLevel *doomMap, const surface_t *surface, const kexVec3 &origin);
const float Distance() const { return distance; }