-
Notifications
You must be signed in to change notification settings - Fork 67
Obb calculation with debug draw #975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
b635208
a81c999
e5cf6fb
12164ac
5a30e80
b6e9c03
f09e2bc
229457c
d572645
b2e73a4
afb4558
d5f7011
32cbb36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| { | ||
|
|
@@ -231,6 +232,26 @@ class NBL_API2 CPolygonGeometryManipulator | |
| EEM_COUNT | ||
| }; | ||
|
|
||
| struct VertexCollection | ||
| { | ||
| using FetchFn = std::function<hlsl::float32_t3(size_t vertexIndex)>; | ||
| FetchFn fetch; | ||
|
Comment on lines
+237
to
+238
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is always runtime polymorphic (wont specialize nicely based on a lambda),
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw I don't think all the OBB stuff should be nested inside |
||
| 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() | ||
| }; | ||
| } | ||
|
Comment on lines
+241
to
+250
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be a different template instantiation of |
||
|
|
||
| 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; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ struct AABB | |
| point_t maxVx; | ||
| }; | ||
|
|
||
|
|
||
| namespace util | ||
| { | ||
| namespace impl | ||
|
|
||
| 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; | ||
|
Comment on lines
+33
to
+35
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use a @karimsayedre which OBB is more useful for you in general, the one that transforms a [0,1]^3 or [-1,1]^3 obb ? |
||
| }; | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation