Reverting normal cone introduction
This commit is contained in:
+2
-1
@@ -10,7 +10,8 @@
|
||||
"inheritEnvironments": [ "msvc_x64" ],
|
||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||
"buildRoot": "C:/Users/Dynamitos/Seele/bin/",
|
||||
"installRoot": "C:/Program Files/Seele"
|
||||
"installRoot": "C:/Program Files/Seele",
|
||||
"addressSanitizerEnabled": true
|
||||
},
|
||||
{
|
||||
"name": "Release",
|
||||
|
||||
@@ -29,18 +29,18 @@ void taskMain(
|
||||
localToClip = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, instance.transformMatrix));
|
||||
// Left
|
||||
viewFrustum.sides[0].n = float3(1, 0, 0);
|
||||
viewFrustum.sides[0].d = 1;
|
||||
viewFrustum.sides[0].d = -1;
|
||||
// Right
|
||||
viewFrustum.sides[1].n = float3(-1, 0, 0);
|
||||
viewFrustum.sides[1].d = 1;
|
||||
viewFrustum.sides[1].d = -1;
|
||||
// Top
|
||||
viewFrustum.sides[2].n = float3(0, -1, 0);
|
||||
viewFrustum.sides[2].d = 1;
|
||||
viewFrustum.sides[2].d = -1;
|
||||
// Bottom
|
||||
viewFrustum.sides[3].n = float3(0, 1, 0);
|
||||
viewFrustum.sides[3].d = 1;
|
||||
viewFrustum.sides[3].d = -1;
|
||||
// Base
|
||||
viewFrustum.basePlane.n = float3(0, 0, 1);
|
||||
viewFrustum.basePlane.n = float3(0, 0, -1);
|
||||
viewFrustum.basePlane.d = 0;
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
@@ -35,13 +35,13 @@ struct Frustum
|
||||
Plane basePlane;
|
||||
bool pointInside(float3 point)
|
||||
{
|
||||
if (dot(basePlane.n, point) + basePlane.d < 0.0f)
|
||||
if (dot(basePlane.n, point) + basePlane.d > 0.0f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for(int p = 0; p < 4; ++p)
|
||||
{
|
||||
if(dot(sides[p].n, point) + sides[p].d < 0.0f)
|
||||
if(dot(sides[p].n, point) + sides[p].d > 0.0f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ struct MeshletDescription
|
||||
uint32_t primitiveCount;
|
||||
uint32_t vertexOffset;
|
||||
uint32_t primitiveOffset;
|
||||
float3 color;
|
||||
float pad;
|
||||
};
|
||||
|
||||
struct MeshData
|
||||
@@ -22,8 +20,8 @@ struct MeshData
|
||||
uint32_t pad0[3];
|
||||
};
|
||||
|
||||
static const uint MAX_VERTICES = 64;
|
||||
static const uint MAX_PRIMITIVES = 126;
|
||||
static const uint MAX_VERTICES = 256;
|
||||
static const uint MAX_PRIMITIVES = 256;
|
||||
static const uint TASK_GROUP_SIZE = 128;
|
||||
static const uint MESH_GROUP_SIZE = 32;
|
||||
static const uint MAX_MESHLETS_PER_MESH = 512;
|
||||
|
||||
@@ -268,7 +268,11 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
|
||||
|
||||
Array<Meshlet> meshlets;
|
||||
meshlets.reserve(indices.size() / (3ull * Gfx::numPrimitivesPerMeshlet));
|
||||
Meshlet::build(positions, indices, meshlets);
|
||||
Meshlet::build(indices, meshlets);
|
||||
for (auto& meshlet : meshlets)
|
||||
{
|
||||
meshlet.calcBoundingBox(positions);
|
||||
}
|
||||
vertexData->loadMesh(id, indices, meshlets);
|
||||
|
||||
collider.physicsMesh.addCollider(positions, indices, Matrix4(1.0f));
|
||||
|
||||
@@ -587,8 +587,8 @@ private:
|
||||
deallocateArray(_data, arraySize);
|
||||
_data = tempArray;
|
||||
}
|
||||
std::allocator_traits<allocator_type>::construct(allocator, &_data[arraySize++], std::forward<Type>(t));
|
||||
return _data[arraySize - 1];
|
||||
std::allocator_traits<allocator_type>::construct(allocator, &_data[arraySize], std::forward<Type>(t));
|
||||
return _data[arraySize++];
|
||||
}
|
||||
template<typename Type>
|
||||
void resizeInternal(size_type newSize, const Type& value) noexcept
|
||||
|
||||
@@ -114,7 +114,6 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
||||
.primitiveCount = m.numPrimitives,
|
||||
.vertexOffset = vertexOffset,
|
||||
.primitiveOffset = primitiveOffset,
|
||||
.color = Vector((float)rand() / RAND_MAX, (float)rand() / RAND_MAX, (float)rand() / RAND_MAX),
|
||||
});
|
||||
}
|
||||
meshData[id].add(MeshData{
|
||||
@@ -244,28 +243,13 @@ VertexData::VertexData()
|
||||
{
|
||||
}
|
||||
|
||||
void Meshlet::build(const Array<Vector>& positions, const Array<uint32>& indices, Array<Meshlet>& meshlets)
|
||||
void Meshlet::build(const Array<uint32>& indices, Array<Meshlet>& meshlets)
|
||||
{
|
||||
std::set<uint32> uniqueVertices;
|
||||
Meshlet current = {
|
||||
.numVertices = 0,
|
||||
.numPrimitives = 0,
|
||||
};
|
||||
auto insertAndGetIndex = [&positions, &uniqueVertices, ¤t](uint32 index) -> int8_t
|
||||
{
|
||||
auto [it, inserted] = uniqueVertices.insert(index);
|
||||
if (inserted)
|
||||
{
|
||||
if (current.numVertices == Gfx::numVerticesPerMeshlet)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
current.uniqueVertices[current.numVertices] = index;
|
||||
current.boundingBox.adjust(positions[index]);
|
||||
return current.numVertices++;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto findIndex = [¤t](uint32 index) -> int {
|
||||
for (uint32 i = 0; i < current.numVertices; ++i)
|
||||
{
|
||||
if (current.uniqueVertices[i] == index)
|
||||
@@ -273,41 +257,52 @@ void Meshlet::build(const Array<Vector>& positions, const Array<uint32>& indices
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// it could be in unique vertices but not in meshlet vertices
|
||||
if (current.numVertices == Gfx::numVerticesPerMeshlet)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
current.uniqueVertices[current.numVertices] = index;
|
||||
return current.numVertices++;
|
||||
};
|
||||
auto completeMeshlet = [&meshlets, ¤t, &uniqueVertices]() {
|
||||
auto completeMeshlet = [&meshlets, ¤t]() {
|
||||
meshlets.add(current);
|
||||
current = {
|
||||
.numVertices = 0,
|
||||
.numPrimitives = 0,
|
||||
};
|
||||
uniqueVertices.clear();
|
||||
};
|
||||
for (size_t faceIndex = 0; faceIndex < indices.size() / 3; ++faceIndex)
|
||||
{
|
||||
auto i1 = insertAndGetIndex(indices[faceIndex * 3 + 0]);
|
||||
auto i2 = insertAndGetIndex(indices[faceIndex * 3 + 1]);
|
||||
auto i3 = insertAndGetIndex(indices[faceIndex * 3 + 2]);
|
||||
if (i1 == -1 || i2 == -1 || i3 == -1)
|
||||
int f1 = findIndex(indices[faceIndex * 3 + 0]);
|
||||
int f2 = findIndex(indices[faceIndex * 3 + 1]);
|
||||
int f3 = findIndex(indices[faceIndex * 3 + 2]);
|
||||
|
||||
if (f1 == -1 || f2 == -1 || f1 == -1)
|
||||
{
|
||||
completeMeshlet();
|
||||
i1 = insertAndGetIndex(indices[faceIndex * 3 + 0]);
|
||||
i2 = insertAndGetIndex(indices[faceIndex * 3 + 1]);
|
||||
i3 = insertAndGetIndex(indices[faceIndex * 3 + 2]);
|
||||
f1 = findIndex(indices[faceIndex * 3 + 0]);
|
||||
f2 = findIndex(indices[faceIndex * 3 + 1]);
|
||||
f3 = findIndex(indices[faceIndex * 3 + 2]);
|
||||
}
|
||||
current.primitiveLayout[current.numPrimitives * 3 + 0] = i1;
|
||||
current.primitiveLayout[current.numPrimitives * 3 + 1] = i2;
|
||||
current.primitiveLayout[current.numPrimitives * 3 + 2] = i3;
|
||||
current.primitiveLayout[current.numPrimitives * 3 + 0] = uint8(f1);
|
||||
current.primitiveLayout[current.numPrimitives * 3 + 1] = uint8(f2);
|
||||
current.primitiveLayout[current.numPrimitives * 3 + 2] = uint8(f3);
|
||||
current.numPrimitives++;
|
||||
if (current.numPrimitives == Gfx::numPrimitivesPerMeshlet)
|
||||
{
|
||||
completeMeshlet();
|
||||
}
|
||||
}
|
||||
if (!uniqueVertices.empty())
|
||||
if (current.numVertices > 0)
|
||||
{
|
||||
completeMeshlet();
|
||||
}
|
||||
}
|
||||
|
||||
void Meshlet::calcBoundingBox(const Array<Vector>& positions)
|
||||
{
|
||||
for (uint32 i = 0; i < numVertices; ++i)
|
||||
{
|
||||
boundingBox.adjust(positions[uniqueVertices[i]]);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,8 @@ struct Meshlet
|
||||
uint8 primitiveLayout[Gfx::numPrimitivesPerMeshlet * 3]; // indices into the uniqueVertices array, only uint8 needed
|
||||
uint32 numVertices;
|
||||
uint32 numPrimitives;
|
||||
static void build(const Array<Vector>& positions, const Array<uint32>& indices, Array<Meshlet>& meshlets);
|
||||
static void build(const Array<uint32>& indices, Array<Meshlet>& meshlets);
|
||||
void calcBoundingBox(const Array<Vector>& positions);
|
||||
};
|
||||
class VertexData
|
||||
{
|
||||
@@ -98,8 +99,6 @@ protected:
|
||||
uint32_t primitiveCount;
|
||||
uint32_t vertexOffset;
|
||||
uint32_t primitiveOffset;
|
||||
Vector color;
|
||||
float pad0;
|
||||
};
|
||||
Map<std::string, MaterialData> materialData;
|
||||
Map<MeshId, Array<MeshData>> meshData;
|
||||
|
||||
Reference in New Issue
Block a user