fixed floors sample

This commit is contained in:
Sandro Sobczyński
2020-11-03 16:44:39 +01:00
parent 5aa2a9bdb5
commit b75b2d6e4f
30 changed files with 331 additions and 224 deletions
+8 -5
View File
@@ -79,11 +79,14 @@ public:
*/
MeshMaterial *getMaterialById(const u32 &t_id) const { return frames[0].getMaterialById(t_id); }
/** Returns bounding box vertex at given index with added mesh position.
* @param o_result Result
* @param offset 0-7. Because, bounding box have 8 corners
/**
* Returns bounding vertex of current frame.
* @param i 0-7. Because, bounding box have 8 corners
*/
void getCurrentBoundingBoxVertex(Vector3 &o_result, const u32 &t_index);
Vector3 &getCurrentBoundingBoxVertex(const u8 &i) { return frames[animState.currentFrame].getBoundingBoxVertex(i); };
/** Returns bounding box of current frame. Size: 8 */
Vector3 *getCurrentBoundingBox() const { return frames[animState.currentFrame].getBoundingBox(); };
// ----
// Setters
@@ -171,7 +174,7 @@ public:
*/
const u8 &isStayAnimationSet() const { return animState.isStayFrameSet; };
/** Check if mesh is visible in view frustum */
/** True when mesh is in view frustum */
u8 isInFrustum(Plane *t_frustumPlanes);
/**
+9 -3
View File
@@ -75,11 +75,17 @@ public:
/** Array of materials. Size of getMaterialsCount() */
MeshMaterial *getMaterials() const { return materials; };
/**
* Returns bounding box (AABB).
* Total length: 8
*/
Vector3 *getBoundingBox() { return boundingBox; };
/**
* Returns bounding box (AABB) vertex.
* Total length: 8
*/
Vector3 &getBoundingBox(const u8 &i) { return boundingBox[i]; };
Vector3 &getBoundingBoxVertex(const u8 &i) { return boundingBox[i]; };
// ----
// Setters
@@ -126,11 +132,11 @@ public:
void allocateMaterials(const u32 &t_val);
/**
* Calculates bounding box (AABB).
* Calculates bounding box (AABB) for frame and for materiaals.
* Should be called by data loader,
* so there is no need to run it again.
*/
void calculateBoundingBox();
void calculateBoundingBoxes();
private:
Vector3 boundingBox[8];
+26 -1
View File
@@ -12,6 +12,8 @@
#define _TYRA_MESH_MATERIAL_
#include <tamtypes.h>
#include "./math/vector3.hpp"
#include "./math/plane.hpp"
/** Class which contains draw instructions for part mesh of mesh.
* Mesh can have many materials.
@@ -58,6 +60,18 @@ public:
/** Array of normal vector faces. Size of getFacesCount() */
u32 *getNormalFaces() const { return normalFaces; };
/**
* Returns bounding box (AABB).
* Total length: 8
*/
Vector3 *getBoundingBox() { return boundingBox; };
/**
* Returns bounding box (AABB) vertex.
* Total length: 8
*/
Vector3 &getBoundingBoxVertex(const u8 &i) { return boundingBox[i]; };
// ----
// Setters
// ----
@@ -93,10 +107,21 @@ public:
/** Set faces count and allocate memory. */
void allocateFaces(const u32 &t_val);
/**
* Do not call this method unless you know what you do.
* Calculates bounding box (AABB).
* Called automatically in mesh frame class on data loading.
*/
void calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount);
/** True when mesh is in view frustum */
u8 isInFrustum(Plane *t_frustumPlanes, const Vector3 &position);
private:
Vector3 boundingBox[8];
u32 facesCount, id;
u32 *vertexFaces, *stFaces, *normalFaces;
u8 _isNameSet, _areFacesAllocated;
u8 _isNameSet, _areFacesAllocated, _isBoundingBoxCalculated;
char *name;
};