Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b635208
Dummy
Aug 25, 2025
a81c999
Merge branch 'master' into obb_calculation
Sep 4, 2025
e5cf6fb
Merge branch 'new_debug_draw' into obb_calculation_with_debug_draw
Sep 4, 2025
12164ac
Implement getTransformOBB for DrawAABB extension
Sep 6, 2025
5a30e80
Move OBB Calculation into its own file
Sep 6, 2025
b6e9c03
Fix create axis aligned bounding box
Sep 6, 2025
f09e2bc
Merge branch 'obb_calculation' into obb_calculation_with_debug_draw
Sep 6, 2025
229457c
Fix Imgui to always render
Sep 16, 2025
d572645
Merge branch 'master' into obb_calculation_with_debug_draw
Dec 28, 2025
b2e73a4
Move obb into its own file
Dec 29, 2025
afb4558
Recover missing COBBGenerator.h file
Dec 29, 2025
d5f7011
Refactor obb calculation and some fixes
Dec 29, 2025
32cbb36
Update CDrawAABB::computeOBBTransform to return float32_t3x4
Dec 29, 2025
be4630b
Fix sqDist calculation
Jan 6, 2026
00affbc
Delete reimplemented code
Jan 6, 2026
d79c703
Remove reimplemented code
Jan 6, 2026
9f18a1f
Fix indentation
Jan 6, 2026
a76f40c
Change calculateOBB interface to use template
Jan 7, 2026
2adc7f4
Add inline specifier
Jan 7, 2026
d23cde3
Change obb to use matrix as member
Jan 7, 2026
02f5bfe
Remove CDrawAABB::getTransformFromOBB
Jan 8, 2026
bcb5276
Merge branch 'master' into obb_calculation_with_debug_draw
AnastaZIuk Jan 13, 2026
0e74738
Fix bug
Jan 14, 2026
34d231e
Merge remote-tracking branch 'origin/obb_calculation_with_debug_draw'…
Jan 14, 2026
cd78818
Merge branch 'master' into obb_calculation_with_debug_draw
kevyuu Jan 14, 2026
153ba1a
Fix bug regarding LargeBaseTriangle computation
Jan 14, 2026
cb71a4b
Add some comment regarding references and credit to the original auth…
Jan 14, 2026
03cb423
Fix bug regarding finding the furthest point from base triangle
Jan 14, 2026
0dc95ef
Add some comment
Jan 14, 2026
6d1cfb2
Add epsilon as argument for computeOBB
Jan 14, 2026
626b802
Merge remote-tracking branch 'origin/obb_calculation_with_debug_draw'…
Jan 14, 2026
b5daf19
Remove old commented code regarding obb calculation
Jan 14, 2026
ccdf991
update examples_tests submodule
AnastaZIuk Jan 14, 2026
b589759
update examples_tests submodule
AnastaZIuk Jan 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions include/nbl/asset/utils/COBBGenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

// Copyright (C) 2018-2023 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h

#ifndef _NBL_ASSET_C_OBB_GENERATOR_H_INCLUDED_
#define _NBL_ASSET_C_OBB_GENERATOR_H_INCLUDED_

#include "nbl/asset/utils/CPolygonGeometryManipulator.h"
#include "nbl/builtin/hlsl/shapes/obb.hlsl"

namespace nbl::asset
{
class COBBGenerator
{
public:

using VertexCollection = CPolygonGeometryManipulator::VertexCollection;

static hlsl::shapes::OBB<> compute(const VertexCollection& vertices);

};
}

#endif
21 changes: 21 additions & 0 deletions include/nbl/asset/utils/CPolygonGeometryManipulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "nbl/asset/ICPUPolygonGeometry.h"
#include "nbl/asset/utils/CGeometryManipulator.h"
#include "nbl/asset/utils/CSmoothNormalGenerator.h"
#include "nbl/builtin/hlsl/shapes/obb.hlsl"

namespace nbl::asset
{
Expand Down Expand Up @@ -231,6 +232,26 @@ class NBL_API2 CPolygonGeometryManipulator
EEM_COUNT
};

struct VertexCollection
{
using FetchFn = std::function<hlsl::float32_t3(size_t vertexIndex)>;
FetchFn fetch;
size_t size;

static auto fromSpan(std::span<const hlsl::float32_t3> vertices) -> VertexCollection
{
return VertexCollection{
.fetch = [data = vertices.data()](size_t vertexIndex)-> hlsl::float32_t3
{
return data[vertexIndex];
},
.size = vertices.size()
};
}

hlsl::float32_t3 operator[](size_t index) const { return fetch(index); }
};
static hlsl::shapes::OBB<3, hlsl::float32_t> calculateOBB(const VertexCollection& vertexCollection);
static core::smart_refctd_ptr<ICPUPolygonGeometry> createUnweldedList(const ICPUPolygonGeometry* inGeo);

using SSNGVertexData = CSmoothNormalGenerator::VertexData;
Expand Down
1 change: 1 addition & 0 deletions include/nbl/builtin/hlsl/shapes/aabb.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct AABB
point_t maxVx;
};


namespace util
{
namespace impl
Expand Down
42 changes: 42 additions & 0 deletions include/nbl/builtin/hlsl/shapes/obb.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (C) 2018-2023 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_BUILTIN_HLSL_SHAPES_OBB_INCLUDED_
#define _NBL_BUILTIN_HLSL_SHAPES_OBB_INCLUDED_

namespace nbl
{
namespace hlsl
{
namespace shapes
{

template<int16_t D=3, typename Scalar=float32_t>
struct OBB
{
using scalar_t = Scalar;
using point_t = vector<Scalar,D>;

static OBB createAxisAligned(point_t mid, point_t len)
{
OBB ret;
ret.mid = mid;
ret.ext = len * 0.5f;
for (auto dim_i = 0; dim_i < D; dim_i++)
{
ret.axes[dim_i] = point_t(0);
ret.axes[dim_i][dim_i] = 1;
}
return ret;
}

point_t mid;
std::array<point_t, D> axes;
point_t ext;
};

}
}
}

#endif
2 changes: 2 additions & 0 deletions include/nbl/ext/DebugDraw/CDrawAABB.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ namespace nbl::ext::debug_draw
return transform;
}

static hlsl::float32_t3x4 getTransformFromOBB(const hlsl::shapes::OBB<3, float>& aabb);

protected:
struct ConstructorParams
{
Expand Down
1 change: 1 addition & 0 deletions src/nbl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ set(NBL_ASSET_SOURCES
# Meshes
asset/utils/CForsythVertexCacheOptimizer.cpp
asset/utils/CSmoothNormalGenerator.cpp
asset/utils/COBBGenerator.cpp
asset/utils/CGeometryCreator.cpp
asset/utils/CPolygonGeometryManipulator.cpp
asset/utils/COverdrawPolygonGeometryOptimizer.cpp
Expand Down
Loading
Loading