mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 22:36:39 +02:00
Code review feedback
This commit is contained in:
parent
0469eafbe4
commit
0404b722e4
5 changed files with 28 additions and 24 deletions
|
@ -275,7 +275,7 @@ void CauterizedModel::updateRenderItems() {
|
||||||
data.setEnableCauterization(enableCauterization);
|
data.setEnableCauterization(enableCauterization);
|
||||||
data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, render::ItemKey::TAG_BITS_ALL);
|
data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, render::ItemKey::TAG_BITS_ALL);
|
||||||
data.setLayer(isLayeredInFront, isLayeredInHUD);
|
data.setLayer(isLayeredInFront, isLayeredInHUD);
|
||||||
data.setShapeKey(invalidatePayloadShapeKey, isWireframe);
|
data.setShapeKey(invalidatePayloadShapeKey, isWireframe, useDualQuaternionSkinning);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ ModelMeshPartPayload::ModelMeshPartPayload(ModelPointer model, int meshIndex, in
|
||||||
|
|
||||||
assert(model && model->isLoaded());
|
assert(model && model->isLoaded());
|
||||||
|
|
||||||
_useDualQuaternionSkinning = model->getUseDualQuaternionSkinning();
|
bool useDualQuaternionSkinning = model->getUseDualQuaternionSkinning();
|
||||||
|
|
||||||
_blendedVertexBuffer = model->_blendedVertexBuffers[_meshIndex];
|
_blendedVertexBuffer = model->_blendedVertexBuffers[_meshIndex];
|
||||||
auto& modelMesh = model->getGeometry()->getMeshes().at(_meshIndex);
|
auto& modelMesh = model->getGeometry()->getMeshes().at(_meshIndex);
|
||||||
|
@ -231,7 +231,7 @@ ModelMeshPartPayload::ModelMeshPartPayload(ModelPointer model, int meshIndex, in
|
||||||
|
|
||||||
updateMeshPart(modelMesh, partIndex);
|
updateMeshPart(modelMesh, partIndex);
|
||||||
|
|
||||||
if (_useDualQuaternionSkinning) {
|
if (useDualQuaternionSkinning) {
|
||||||
computeAdjustedLocalBound(state.clusterDualQuaternions);
|
computeAdjustedLocalBound(state.clusterDualQuaternions);
|
||||||
} else {
|
} else {
|
||||||
computeAdjustedLocalBound(state.clusterMatrices);
|
computeAdjustedLocalBound(state.clusterMatrices);
|
||||||
|
@ -239,7 +239,7 @@ ModelMeshPartPayload::ModelMeshPartPayload(ModelPointer model, int meshIndex, in
|
||||||
|
|
||||||
updateTransform(transform, offsetTransform);
|
updateTransform(transform, offsetTransform);
|
||||||
Transform renderTransform = transform;
|
Transform renderTransform = transform;
|
||||||
if (_useDualQuaternionSkinning) {
|
if (useDualQuaternionSkinning) {
|
||||||
if (state.clusterDualQuaternions.size() == 1) {
|
if (state.clusterDualQuaternions.size() == 1) {
|
||||||
const auto& dq = state.clusterDualQuaternions[0];
|
const auto& dq = state.clusterDualQuaternions[0];
|
||||||
Transform transform(dq.getRotation(),
|
Transform transform(dq.getRotation(),
|
||||||
|
@ -281,6 +281,13 @@ void ModelMeshPartPayload::notifyLocationChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelMeshPartPayload::updateClusterBuffer(const std::vector<glm::mat4>& clusterMatrices) {
|
void ModelMeshPartPayload::updateClusterBuffer(const std::vector<glm::mat4>& clusterMatrices) {
|
||||||
|
|
||||||
|
// reset cluster buffer if we change the cluster buffer type
|
||||||
|
if (_clusterBufferType != ClusterBufferType::Matrices) {
|
||||||
|
_clusterBuffer.reset();
|
||||||
|
}
|
||||||
|
_clusterBufferType = ClusterBufferType::Matrices;
|
||||||
|
|
||||||
// Once computed the cluster matrices, update the buffer(s)
|
// Once computed the cluster matrices, update the buffer(s)
|
||||||
if (clusterMatrices.size() > 1) {
|
if (clusterMatrices.size() > 1) {
|
||||||
if (!_clusterBuffer) {
|
if (!_clusterBuffer) {
|
||||||
|
@ -295,6 +302,13 @@ void ModelMeshPartPayload::updateClusterBuffer(const std::vector<glm::mat4>& clu
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelMeshPartPayload::updateClusterBuffer(const std::vector<Model::TransformDualQuaternion>& clusterDualQuaternions) {
|
void ModelMeshPartPayload::updateClusterBuffer(const std::vector<Model::TransformDualQuaternion>& clusterDualQuaternions) {
|
||||||
|
|
||||||
|
// reset cluster buffer if we change the cluster buffer type
|
||||||
|
if (_clusterBufferType != ClusterBufferType::DualQuaternions) {
|
||||||
|
_clusterBuffer.reset();
|
||||||
|
}
|
||||||
|
_clusterBufferType = ClusterBufferType::DualQuaternions;
|
||||||
|
|
||||||
// Once computed the cluster matrices, update the buffer(s)
|
// Once computed the cluster matrices, update the buffer(s)
|
||||||
if (clusterDualQuaternions.size() > 1) {
|
if (clusterDualQuaternions.size() > 1) {
|
||||||
if (!_clusterBuffer) {
|
if (!_clusterBuffer) {
|
||||||
|
@ -360,7 +374,7 @@ int ModelMeshPartPayload::getLayer() const {
|
||||||
return _layer;
|
return _layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelMeshPartPayload::setShapeKey(bool invalidateShapeKey, bool isWireframe) {
|
void ModelMeshPartPayload::setShapeKey(bool invalidateShapeKey, bool isWireframe, bool useDualQuaternionSkinning) {
|
||||||
if (invalidateShapeKey) {
|
if (invalidateShapeKey) {
|
||||||
_shapeKey = ShapeKey::Builder::invalid();
|
_shapeKey = ShapeKey::Builder::invalid();
|
||||||
return;
|
return;
|
||||||
|
@ -407,7 +421,7 @@ void ModelMeshPartPayload::setShapeKey(bool invalidateShapeKey, bool isWireframe
|
||||||
if (isWireframe) {
|
if (isWireframe) {
|
||||||
builder.withWireframe();
|
builder.withWireframe();
|
||||||
}
|
}
|
||||||
if (_useDualQuaternionSkinning && isSkinned) {
|
if (isSkinned && useDualQuaternionSkinning) {
|
||||||
builder.withDualQuatSkinned();
|
builder.withDualQuatSkinned();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,10 +511,3 @@ void ModelMeshPartPayload::computeAdjustedLocalBound(const std::vector<Model::Tr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelMeshPartPayload::setUseDualQuaternionSkinning(bool value) {
|
|
||||||
if (value != _useDualQuaternionSkinning) {
|
|
||||||
_clusterBuffer.reset();
|
|
||||||
}
|
|
||||||
_useDualQuaternionSkinning = value;
|
|
||||||
}
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ public:
|
||||||
void render(RenderArgs* args) override;
|
void render(RenderArgs* args) override;
|
||||||
|
|
||||||
void setLayer(bool isLayeredInFront, bool isLayeredInHUD);
|
void setLayer(bool isLayeredInFront, bool isLayeredInHUD);
|
||||||
void setShapeKey(bool invalidateShapeKey, bool isWireframe);
|
void setShapeKey(bool invalidateShapeKey, bool isWireframe, bool useDualQuaternionSkinning);
|
||||||
|
|
||||||
// ModelMeshPartPayload functions to perform render
|
// ModelMeshPartPayload functions to perform render
|
||||||
void bindMesh(gpu::Batch& batch) override;
|
void bindMesh(gpu::Batch& batch) override;
|
||||||
|
@ -120,17 +120,17 @@ public:
|
||||||
// dual quaternion skinning
|
// dual quaternion skinning
|
||||||
void computeAdjustedLocalBound(const std::vector<Model::TransformDualQuaternion>& clusterDualQuaternions);
|
void computeAdjustedLocalBound(const std::vector<Model::TransformDualQuaternion>& clusterDualQuaternions);
|
||||||
|
|
||||||
void setUseDualQuaternionSkinning(bool value);
|
|
||||||
|
|
||||||
gpu::BufferPointer _clusterBuffer;
|
gpu::BufferPointer _clusterBuffer;
|
||||||
|
|
||||||
|
enum class ClusterBufferType { Matrices, DualQuaternions };
|
||||||
|
ClusterBufferType _clusterBufferType { ClusterBufferType::Matrices };
|
||||||
|
|
||||||
int _meshIndex;
|
int _meshIndex;
|
||||||
int _shapeID;
|
int _shapeID;
|
||||||
|
|
||||||
bool _isSkinned{ false };
|
bool _isSkinned{ false };
|
||||||
bool _isBlendShaped { false };
|
bool _isBlendShaped { false };
|
||||||
bool _hasTangents { false };
|
bool _hasTangents { false };
|
||||||
bool _useDualQuaternionSkinning { false };
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initCache(const ModelPointer& model);
|
void initCache(const ModelPointer& model);
|
||||||
|
|
|
@ -288,7 +288,6 @@ void Model::updateRenderItems() {
|
||||||
invalidatePayloadShapeKey, isWireframe, isVisible,
|
invalidatePayloadShapeKey, isWireframe, isVisible,
|
||||||
viewTagBits, isLayeredInFront,
|
viewTagBits, isLayeredInFront,
|
||||||
isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) {
|
isLayeredInHUD, isGroupCulled](ModelMeshPartPayload& data) {
|
||||||
data.setUseDualQuaternionSkinning(useDualQuaternionSkinning);
|
|
||||||
if (useDualQuaternionSkinning) {
|
if (useDualQuaternionSkinning) {
|
||||||
data.updateClusterBuffer(meshState.clusterDualQuaternions);
|
data.updateClusterBuffer(meshState.clusterDualQuaternions);
|
||||||
} else {
|
} else {
|
||||||
|
@ -314,7 +313,7 @@ void Model::updateRenderItems() {
|
||||||
|
|
||||||
data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled);
|
data.updateKey(isVisible, isLayeredInFront || isLayeredInHUD, viewTagBits, isGroupCulled);
|
||||||
data.setLayer(isLayeredInFront, isLayeredInHUD);
|
data.setLayer(isLayeredInFront, isLayeredInHUD);
|
||||||
data.setShapeKey(invalidatePayloadShapeKey, isWireframe);
|
data.setShapeKey(invalidatePayloadShapeKey, isWireframe, useDualQuaternionSkinning);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1591,8 +1590,7 @@ void Model::addMaterial(graphics::MaterialLayer material, const std::string& par
|
||||||
data.addMaterial(material);
|
data.addMaterial(material);
|
||||||
// if the material changed, we might need to update our item key or shape key
|
// if the material changed, we might need to update our item key or shape key
|
||||||
data.updateKey(visible, layeredInFront || layeredInHUD, viewTagBits);
|
data.updateKey(visible, layeredInFront || layeredInHUD, viewTagBits);
|
||||||
data.setUseDualQuaternionSkinning(useDualQuaternionSkinning);
|
data.setShapeKey(invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning);
|
||||||
data.setShapeKey(invalidatePayloadShapeKey, wireframe);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1618,8 +1616,7 @@ void Model::removeMaterial(graphics::MaterialPointer material, const std::string
|
||||||
data.removeMaterial(material);
|
data.removeMaterial(material);
|
||||||
// if the material changed, we might need to update our item key or shape key
|
// if the material changed, we might need to update our item key or shape key
|
||||||
data.updateKey(visible, layeredInFront || layeredInHUD, viewTagBits);
|
data.updateKey(visible, layeredInFront || layeredInHUD, viewTagBits);
|
||||||
data.setUseDualQuaternionSkinning(useDualQuaternionSkinning);
|
data.setShapeKey(invalidatePayloadShapeKey, wireframe, useDualQuaternionSkinning);
|
||||||
data.setShapeKey(invalidatePayloadShapeKey, wireframe);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -602,5 +602,5 @@ glm::vec3 randVector() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNonUniformScale(const glm::vec3& scale) {
|
bool isNonUniformScale(const glm::vec3& scale) {
|
||||||
return fabsf(scale.x - scale.y) > EPSILON || fabsf(scale.y - scale.z) > EPSILON;
|
return fabsf(scale.x - scale.y) > EPSILON || fabsf(scale.y - scale.z) > EPSILON || fabsf(scale.z - scale.x);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue