adding tex coords
This commit is contained in:
+2
-1
@@ -31,6 +31,7 @@ void BVH::generate()
|
||||
for (uint32_t i = 0; i < model->positions.size(); ++i)
|
||||
{
|
||||
positionPool.push_back(model->positions[i]);
|
||||
texCoordsPool.push_back(model->texCoords[i]);
|
||||
}
|
||||
for (uint32_t i = 0; i < model->indices.size(); ++i)
|
||||
{
|
||||
@@ -120,7 +121,7 @@ std::vector<IntersectionInfo> BVH::generateIntersections(const PNode& currentNod
|
||||
return leftResults;
|
||||
}
|
||||
|
||||
std::optional<IntersectionInfo> BVH::intersectModel(ModelReference reference, const Ray ray) const
|
||||
std::optional<IntersectionInfo> BVH::intersectModel(const ModelReference& reference, const Ray ray) const
|
||||
{
|
||||
std::optional<IntersectionInfo> intersection = {};
|
||||
float distance = 0;
|
||||
|
||||
+5
-4
@@ -8,9 +8,9 @@
|
||||
|
||||
struct ModelReference
|
||||
{
|
||||
uint32_t positionOffset;
|
||||
uint32_t indicesOffset;
|
||||
uint32_t numIndices;
|
||||
uint32_t positionOffset = 0;
|
||||
uint32_t indicesOffset = 0;
|
||||
uint32_t numIndices = 0;
|
||||
};
|
||||
|
||||
class BVH
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
|
||||
private:
|
||||
std::vector<glm::vec3> positionPool;
|
||||
std::vector<glm::vec2> texCoordsPool;
|
||||
std::vector<glm::uvec3> indicesPool;
|
||||
std::vector<glm::vec3> edgesPool;
|
||||
std::vector<glm::vec3> faceNormalsPool;
|
||||
@@ -42,5 +43,5 @@ private:
|
||||
std::vector<PModel> models;
|
||||
|
||||
std::vector<IntersectionInfo> generateIntersections(const PNode& currentNode, Ray ray) const;
|
||||
std::optional<IntersectionInfo> intersectModel(ModelReference reference, Ray ray) const;
|
||||
std::optional<IntersectionInfo> intersectModel(const ModelReference& reference, Ray ray) const;
|
||||
};
|
||||
@@ -21,6 +21,7 @@ class Model
|
||||
public:
|
||||
AABB boundingBox;
|
||||
std::vector<glm::vec3> positions;
|
||||
std::vector<glm::vec2> texCoords;
|
||||
std::vector<glm::uvec3> indices;
|
||||
std::vector<glm::vec3> edges;
|
||||
std::vector<glm::vec3> faceNormals;
|
||||
|
||||
@@ -19,6 +19,7 @@ std::vector<PModel> ModelLoader::loadModel(std::string_view filename)
|
||||
{
|
||||
auto aiVert = mesh->mVertices[v];
|
||||
model->positions.push_back(glm::vec3(aiVert.x, aiVert.y, aiVert.z));
|
||||
model->texCoords.push_back(glm::vec2(mesh->mTextureCoords[0][v].x, mesh->mTextureCoords[0][v].y));
|
||||
aabb.adjust(model->positions.back());
|
||||
}
|
||||
for (int i = 0; i < mesh->mNumFaces; ++i)
|
||||
|
||||
Reference in New Issue
Block a user