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