Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5584: Start migrating the ModelScaleManipulator
- Loading branch information
1 parent
f006295
commit df5fa39
Showing
14 changed files
with
161 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#pragma once | ||
|
||
#include "math/AABB.h" | ||
#include "render/RenderableGeometry.h" | ||
#include "render/RenderableBox.h" | ||
|
||
namespace selection | ||
{ | ||
|
||
class RenderableBoundingBoxes : | ||
public render::RenderableGeometry | ||
{ | ||
private: | ||
const std::vector<AABB>& _aabbs; | ||
bool _needsUpdate; | ||
Vector4 _colour; | ||
|
||
public: | ||
RenderableBoundingBoxes(const std::vector<AABB>& aabbs, const Vector4& colour = { 1,1,1,1 }) : | ||
_aabbs(aabbs), | ||
_needsUpdate(true), | ||
_colour(colour) | ||
{} | ||
|
||
void queueUpdate() | ||
{ | ||
_needsUpdate = true; | ||
} | ||
|
||
protected: | ||
void updateGeometry() override | ||
{ | ||
if (!_needsUpdate) return; | ||
|
||
_needsUpdate = false; | ||
|
||
std::vector<ArbitraryMeshVertex> vertices; | ||
std::vector<unsigned int> indices; | ||
|
||
static auto WireframeBoxIndices = render::detail::generateWireframeBoxIndices(); | ||
|
||
vertices.reserve(_aabbs.size() * 8); // 8 vertices per box | ||
indices.reserve(WireframeBoxIndices.size() * _aabbs.size()); // indices per box * boxes | ||
|
||
for (const auto& aabb : _aabbs) | ||
{ | ||
// Calculate the corner vertices of this bounding box | ||
Vector3 max(aabb.origin + aabb.extents); | ||
Vector3 min(aabb.origin - aabb.extents); | ||
|
||
auto boxVertices = render::detail::getWireframeBoxVertices(min, max, _colour); | ||
|
||
auto indexOffset = static_cast<unsigned int>(vertices.size()); | ||
|
||
for (const auto& vertex : boxVertices) | ||
{ | ||
vertices.insert(vertices.begin(), | ||
std::make_move_iterator(boxVertices.begin()), | ||
std::make_move_iterator(boxVertices.end())); | ||
} | ||
|
||
for (auto index : WireframeBoxIndices) | ||
{ | ||
indices.push_back(indexOffset + index); | ||
} | ||
} | ||
|
||
RenderableGeometry::updateGeometry(render::GeometryType::Lines, vertices, indices); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters