moved aabb calcs

This commit is contained in:
Sandro Sobczyński
2020-10-31 10:04:58 +01:00
parent 24016ffa7e
commit ebf2a9ac24
9 changed files with 173 additions and 53 deletions
+1 -3
View File
@@ -35,7 +35,6 @@ public:
DffModel *dff;
float scale;
color_t color;
Vector3 boxVertices[8];
Mesh();
~Mesh();
@@ -55,7 +54,7 @@ public:
u8 isMd2Loaded, isObjLoaded, isDffLoaded, isSpecInitialized;
clutbuffer_t clut;
lod_t lod;
MeshTexture *textures;
MeshTexture **textures;
private:
void setupLodAndClut();
@@ -63,7 +62,6 @@ private:
u32 verticesCount;
Vector3 *vertices;
void loadTextures(char *t_subfolder, char *t_extension);
void computeBoundingBox();
void setVerticesReference(u32 t_verticesCount, Vector3 *t_verticesRef);
void createSpecIfNotCreated();
void setDefaultColor();
+20 -1
View File
@@ -62,6 +62,12 @@ public:
/** Array of materials. Size of getMaterialsCount() */
MeshMaterial *getMaterials() const { return materials; };
/**
* Returns bounding box (AABB) vertex.
* Total length: 8
*/
Vector3 &getBoundingBox(const u8 &i) { return boundingBox[i]; };
// ----
// Setters
// ----
@@ -92,6 +98,7 @@ public:
const u8 &areVerticesAllocated() const { return _areVerticesAllocated; };
const u8 &areNormalsAllocated() const { return _areNormalsAllocated; };
const u8 &areMaterialsAllocated() const { return _areMaterialsAllocated; };
const u8 &isBoundingBoxCalculated() const { return _isBoundingBoxCalculated; };
/** Set STs count and allocate memory. */
void allocateSTs(const u32 &t_val);
@@ -105,8 +112,20 @@ public:
/** Set materials count and allocate memory. */
void allocateMaterials(const u32 &t_val);
/**
* Calculates bounding box (AABB).
* Should be called by data loader,
* so there is no need to run it again.
*/
void calculateBoundingBox();
private:
u8 _areSTsAllocated, _areVerticesAllocated, _areNormalsAllocated, _areMaterialsAllocated;
Vector3 boundingBox[8];
u8 _areSTsAllocated,
_areVerticesAllocated,
_areNormalsAllocated,
_areMaterialsAllocated,
_isBoundingBoxCalculated;
u32 vertexCount, stsCount, normalsCount, materialsCount;
MeshMaterial *materials;
Point *sts __attribute__((aligned(16)));
@@ -0,0 +1,33 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _TYRA_TEXTURE_REPOSITORY_
#define _TYRA_TEXTURE_REPOSITORY_
#include <tamtypes.h>
#include <draw_buffers.h>
#include "../models/mesh.hpp"
/** Class responsible for intializing draw env, textures and buffers */
class TextureRepository
{
public:
TextureRepository();
~TextureRepository();
private:
void allocateTextureBuffer(u16 t_width, u16 t_height);
void deallocateTextureBuffer();
void changeTexture(Mesh *t_mesh, u8 t_textureIndex);
texbuffer_t textureBuffer;
};
#endif