Merge: Bounding

This commit is contained in:
2025-11-18 23:50:18 +09:00
parent bb848b0517
commit d0acaada65
5 changed files with 278 additions and 3 deletions

View File

@@ -111,6 +111,18 @@ std::shared_ptr<MeshAsset> AssetManager::getPrimitive(std::string_view name) con
if (auto m = findBy("Sphere")) return m;
return {};
}
if (name == std::string_view("plane") || name == std::string_view("Plane"))
{
if (auto m = findBy("plane")) return m;
if (auto m = findBy("Plane")) return m;
return {};
}
if (name == std::string_view("capsule") || name == std::string_view("Capsule"))
{
if (auto m = findBy("capsule")) return m;
if (auto m = findBy("Capsule")) return m;
return {};
}
return {};
}
@@ -145,6 +157,16 @@ std::shared_ptr<MeshAsset> AssetManager::createMesh(const MeshCreateInfo &info)
vertsSpan = tmpVerts;
indsSpan = tmpInds;
break;
case MeshGeometryDesc::Type::Plane:
primitives::buildPlane(tmpVerts, tmpInds);
vertsSpan = tmpVerts;
indsSpan = tmpInds;
break;
case MeshGeometryDesc::Type::Capsule:
primitives::buildCapsule(tmpVerts, tmpInds);
vertsSpan = tmpVerts;
indsSpan = tmpInds;
break;
}
// Ensure tangents exist for primitives (and provided geometry if needed)
@@ -246,7 +268,15 @@ std::shared_ptr<MeshAsset> AssetManager::createMesh(const MeshCreateInfo &info)
case MeshGeometryDesc::Type::Sphere:
surf.bounds.type = BoundsType::Sphere;
break;
case MeshGeometryDesc::Type::Capsule:
surf.bounds.type = BoundsType::Capsule;
break;
case MeshGeometryDesc::Type::Cube:
surf.bounds.type = BoundsType::Box;
break;
case MeshGeometryDesc::Type::Plane:
surf.bounds.type = BoundsType::Box;
break;
case MeshGeometryDesc::Type::Provided:
default:
surf.bounds.type = BoundsType::Box;

View File

@@ -40,7 +40,7 @@ public:
struct MeshGeometryDesc
{
enum class Type { Provided, Cube, Sphere };
enum class Type { Provided, Cube, Sphere, Plane, Capsule };
Type type = Type::Provided;
std::span<Vertex> vertices{};

View File

@@ -17,6 +17,7 @@
#include "core/texture_cache.h"
#include "core/ibl_manager.h"
#include "engine_context.h"
#include <vk_types.h>
namespace {