mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 03:53:52 +02:00
Merge pull request #9530 from AndrewMeadows/computeBoundsOutsideLambda
compute Model's local bounds outside pending changes queue
This commit is contained in:
commit
04d5173328
4 changed files with 29 additions and 8 deletions
|
@ -374,12 +374,7 @@ void ModelMeshPartPayload::updateTransformForSkinnedMesh(const Transform& transf
|
|||
_transform = transform;
|
||||
|
||||
if (clusterMatrices.size() > 0) {
|
||||
_worldBound = AABox();
|
||||
for (auto& clusterMatrix : clusterMatrices) {
|
||||
AABox clusterBound = _localBound;
|
||||
clusterBound.transform(clusterMatrix);
|
||||
_worldBound += clusterBound;
|
||||
}
|
||||
_worldBound = _adjustedLocalBound;
|
||||
_worldBound.transform(_transform);
|
||||
if (clusterMatrices.size() == 1) {
|
||||
_transform = _transform.worldTransform(Transform(clusterMatrices[0]));
|
||||
|
@ -612,3 +607,15 @@ void ModelMeshPartPayload::render(RenderArgs* args) const {
|
|||
const int INDICES_PER_TRIANGLE = 3;
|
||||
args->_details._trianglesRendered += _drawPart._numIndices / INDICES_PER_TRIANGLE;
|
||||
}
|
||||
|
||||
void ModelMeshPartPayload::computeAdjustedLocalBound(const QVector<glm::mat4>& clusterMatrices) {
|
||||
_adjustedLocalBound = _localBound;
|
||||
if (clusterMatrices.size() > 0) {
|
||||
_adjustedLocalBound.transform(clusterMatrices[0]);
|
||||
for (int i = 1; i < clusterMatrices.size(); ++i) {
|
||||
AABox clusterBound = _localBound;
|
||||
clusterBound.transform(clusterMatrices[i]);
|
||||
_adjustedLocalBound += clusterBound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// ModelMeshPartPayload.h
|
||||
// MeshPartPayload.h
|
||||
// interface/src/renderer
|
||||
//
|
||||
// Created by Sam Gateau on 10/3/15.
|
||||
|
@ -61,6 +61,7 @@ public:
|
|||
bool _hasColorAttrib { false };
|
||||
|
||||
model::Box _localBound;
|
||||
model::Box _adjustedLocalBound;
|
||||
mutable model::Box _worldBound;
|
||||
std::shared_ptr<const model::Mesh> _drawMesh;
|
||||
|
||||
|
@ -105,6 +106,8 @@ public:
|
|||
|
||||
void initCache();
|
||||
|
||||
void computeAdjustedLocalBound(const QVector<glm::mat4>& clusterMatrices);
|
||||
|
||||
Model* _model;
|
||||
|
||||
int _meshIndex;
|
||||
|
|
|
@ -1149,6 +1149,8 @@ void Model::simulate(float deltaTime, bool fullUpdate) {
|
|||
// update the world space transforms for all joints
|
||||
glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset);
|
||||
updateRig(deltaTime, parentTransform);
|
||||
|
||||
computeMeshPartLocalBounds();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1158,6 +1160,14 @@ void Model::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
_rig->updateAnimations(deltaTime, parentTransform);
|
||||
}
|
||||
|
||||
void Model::computeMeshPartLocalBounds() {
|
||||
for (auto& part : _modelMeshRenderItemsSet) {
|
||||
assert(part->_meshIndex < _modelMeshRenderItemsSet.size());
|
||||
const Model::MeshState& state = _meshStates.at(part->_meshIndex);
|
||||
part->computeAdjustedLocalBound(state.clusterMatrices);
|
||||
}
|
||||
}
|
||||
|
||||
// virtual
|
||||
void Model::updateClusterMatrices() {
|
||||
PerformanceTimer perfTimer("Model::updateClusterMatrices");
|
||||
|
@ -1334,6 +1344,7 @@ void Model::createVisibleRenderItemSet() {
|
|||
shapeID++;
|
||||
}
|
||||
}
|
||||
computeMeshPartLocalBounds();
|
||||
}
|
||||
|
||||
void Model::createCollisionRenderItemSet() {
|
||||
|
|
|
@ -244,7 +244,6 @@ public:
|
|||
public:
|
||||
QVector<glm::mat4> clusterMatrices;
|
||||
gpu::BufferPointer clusterBuffer;
|
||||
|
||||
};
|
||||
|
||||
const MeshState& getMeshState(int index) { return _meshStates.at(index); }
|
||||
|
@ -319,6 +318,7 @@ protected:
|
|||
void scaleToFit();
|
||||
void snapToRegistrationPoint();
|
||||
|
||||
void computeMeshPartLocalBounds();
|
||||
virtual void updateRig(float deltaTime, glm::mat4 parentTransform);
|
||||
|
||||
/// Restores the indexed joint to its default position.
|
||||
|
|
Loading…
Reference in a new issue