mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 07:43:57 +02:00
please work
This commit is contained in:
parent
584d39744f
commit
cde2dc2eaa
6 changed files with 18 additions and 12 deletions
|
@ -102,7 +102,7 @@ void CauterizedModel::createRenderItemSet() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CauterizedModel::updateClusterMatrices(bool triggerBlendshapes) {
|
void CauterizedModel::updateClusterMatrices() {
|
||||||
PerformanceTimer perfTimer("CauterizedModel::updateClusterMatrices");
|
PerformanceTimer perfTimer("CauterizedModel::updateClusterMatrices");
|
||||||
|
|
||||||
if (!_needsUpdateClusterMatrices || !isLoaded()) {
|
if (!_needsUpdateClusterMatrices || !isLoaded()) {
|
||||||
|
@ -175,7 +175,7 @@ void CauterizedModel::updateClusterMatrices(bool triggerBlendshapes) {
|
||||||
|
|
||||||
// post the blender if we're not currently waiting for one to finish
|
// post the blender if we're not currently waiting for one to finish
|
||||||
auto modelBlender = DependencyManager::get<ModelBlender>();
|
auto modelBlender = DependencyManager::get<ModelBlender>();
|
||||||
if (triggerBlendshapes && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
|
if (_blendedVertexBuffersInitialized && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
|
||||||
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
|
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
|
||||||
modelBlender->noteRequiresBlend(getThisPointer());
|
modelBlender->noteRequiresBlend(getThisPointer());
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
|
|
||||||
void createRenderItemSet() override;
|
void createRenderItemSet() override;
|
||||||
|
|
||||||
virtual void updateClusterMatrices(bool triggerBlendshapes = true) override;
|
virtual void updateClusterMatrices() override;
|
||||||
void updateRenderItems() override;
|
void updateRenderItems() override;
|
||||||
|
|
||||||
const Model::MeshState& getCauterizeMeshState(int index) const;
|
const Model::MeshState& getCauterizeMeshState(int index) const;
|
||||||
|
|
|
@ -976,7 +976,7 @@ bool Model::addToScene(const render::ScenePointer& scene,
|
||||||
render::Transaction& transaction,
|
render::Transaction& transaction,
|
||||||
render::Item::Status::Getters& statusGetters) {
|
render::Item::Status::Getters& statusGetters) {
|
||||||
if (!_addedToScene && isLoaded()) {
|
if (!_addedToScene && isLoaded()) {
|
||||||
updateClusterMatrices(false);
|
updateClusterMatrices();
|
||||||
if (_modelMeshRenderItems.empty()) {
|
if (_modelMeshRenderItems.empty()) {
|
||||||
createRenderItemSet();
|
createRenderItemSet();
|
||||||
}
|
}
|
||||||
|
@ -1307,6 +1307,7 @@ void Blender::run() {
|
||||||
if (mesh.blendshapes.isEmpty()) {
|
if (mesh.blendshapes.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vertices += mesh.vertices;
|
vertices += mesh.vertices;
|
||||||
normalsAndTangents += mesh.normalsAndTangents;
|
normalsAndTangents += mesh.normalsAndTangents;
|
||||||
glm::vec3* meshVertices = vertices.data() + offset;
|
glm::vec3* meshVertices = vertices.data() + offset;
|
||||||
|
@ -1486,7 +1487,7 @@ void Model::computeMeshPartLocalBounds() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
void Model::updateClusterMatrices(bool triggerBlendshapes) {
|
void Model::updateClusterMatrices() {
|
||||||
DETAILED_PERFORMANCE_TIMER("Model::updateClusterMatrices");
|
DETAILED_PERFORMANCE_TIMER("Model::updateClusterMatrices");
|
||||||
|
|
||||||
if (!_needsUpdateClusterMatrices || !isLoaded()) {
|
if (!_needsUpdateClusterMatrices || !isLoaded()) {
|
||||||
|
@ -1515,7 +1516,7 @@ void Model::updateClusterMatrices(bool triggerBlendshapes) {
|
||||||
|
|
||||||
// post the blender if we're not currently waiting for one to finish
|
// post the blender if we're not currently waiting for one to finish
|
||||||
auto modelBlender = DependencyManager::get<ModelBlender>();
|
auto modelBlender = DependencyManager::get<ModelBlender>();
|
||||||
if (triggerBlendshapes && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
|
if (_blendedVertexBuffersInitialized && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
|
||||||
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
|
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
|
||||||
modelBlender->noteRequiresBlend(getThisPointer());
|
modelBlender->noteRequiresBlend(getThisPointer());
|
||||||
}
|
}
|
||||||
|
@ -1552,7 +1553,7 @@ void Model::setBlendedVertices(int blendNumber, const Geometry::WeakPointer& geo
|
||||||
const auto vertexCount = mesh.vertices.size();
|
const auto vertexCount = mesh.vertices.size();
|
||||||
const auto verticesSize = vertexCount * sizeof(glm::vec3);
|
const auto verticesSize = vertexCount * sizeof(glm::vec3);
|
||||||
const auto& buffer = _blendedVertexBuffers[i];
|
const auto& buffer = _blendedVertexBuffers[i];
|
||||||
assert(buffer);
|
assert(buffer && _blendedVertexBuffersInitialized);
|
||||||
buffer->resize(mesh.vertices.size() * sizeof(glm::vec3) + mesh.normalsAndTangents.size() * sizeof(NormalType));
|
buffer->resize(mesh.vertices.size() * sizeof(glm::vec3) + mesh.normalsAndTangents.size() * sizeof(NormalType));
|
||||||
buffer->setSubData(0, verticesSize, (gpu::Byte*) vertices.constData() + index * sizeof(glm::vec3));
|
buffer->setSubData(0, verticesSize, (gpu::Byte*) vertices.constData() + index * sizeof(glm::vec3));
|
||||||
buffer->setSubData(verticesSize, mesh.normalsAndTangents.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data() + normalAndTangentIndex * sizeof(NormalType));
|
buffer->setSubData(verticesSize, mesh.normalsAndTangents.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data() + normalAndTangentIndex * sizeof(NormalType));
|
||||||
|
@ -1565,6 +1566,7 @@ void Model::setBlendedVertices(int blendNumber, const Geometry::WeakPointer& geo
|
||||||
void Model::deleteGeometry() {
|
void Model::deleteGeometry() {
|
||||||
_deleteGeometryCounter++;
|
_deleteGeometryCounter++;
|
||||||
_blendedVertexBuffers.clear();
|
_blendedVertexBuffers.clear();
|
||||||
|
_blendedVertexBuffersInitialized = false;
|
||||||
_meshStates.clear();
|
_meshStates.clear();
|
||||||
_rig.destroyAnimGraph();
|
_rig.destroyAnimGraph();
|
||||||
_blendedBlendshapeCoefficients.clear();
|
_blendedBlendshapeCoefficients.clear();
|
||||||
|
@ -1630,6 +1632,7 @@ void Model::initializeBlendshapes(const FBXMesh& mesh, int index) {
|
||||||
_blendedVertexBuffers[index]->setSubData(0, verticesSize, (const gpu::Byte*) mesh.vertices.constData());
|
_blendedVertexBuffers[index]->setSubData(0, verticesSize, (const gpu::Byte*) mesh.vertices.constData());
|
||||||
_blendedVertexBuffers[index]->setSubData(verticesSize, normalsAndTangents.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data());
|
_blendedVertexBuffers[index]->setSubData(verticesSize, normalsAndTangents.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data());
|
||||||
mesh.normalsAndTangents = normalsAndTangents;
|
mesh.normalsAndTangents = normalsAndTangents;
|
||||||
|
_blendedVertexBuffersInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::createRenderItemSet() {
|
void Model::createRenderItemSet() {
|
||||||
|
|
|
@ -159,7 +159,7 @@ public:
|
||||||
bool getSnapModelToRegistrationPoint() { return _snapModelToRegistrationPoint; }
|
bool getSnapModelToRegistrationPoint() { return _snapModelToRegistrationPoint; }
|
||||||
|
|
||||||
virtual void simulate(float deltaTime, bool fullUpdate = true);
|
virtual void simulate(float deltaTime, bool fullUpdate = true);
|
||||||
virtual void updateClusterMatrices(bool triggerBlendshapes = true);
|
virtual void updateClusterMatrices();
|
||||||
|
|
||||||
/// Returns a reference to the shared geometry.
|
/// Returns a reference to the shared geometry.
|
||||||
const Geometry::Pointer& getGeometry() const { return _renderGeometry; }
|
const Geometry::Pointer& getGeometry() const { return _renderGeometry; }
|
||||||
|
@ -345,6 +345,8 @@ public:
|
||||||
void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName);
|
void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName);
|
||||||
void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName);
|
void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName);
|
||||||
|
|
||||||
|
bool areBlendedVertexBuffersInitialized(int index) { return _blendedVertexBuffersInitialized; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadURLFinished(bool success);
|
void loadURLFinished(bool success);
|
||||||
|
|
||||||
|
@ -424,8 +426,9 @@ protected:
|
||||||
QUrl _url;
|
QUrl _url;
|
||||||
|
|
||||||
std::unordered_map<int, gpu::BufferPointer> _blendedVertexBuffers;
|
std::unordered_map<int, gpu::BufferPointer> _blendedVertexBuffers;
|
||||||
|
bool _blendedVertexBuffersInitialized { false };
|
||||||
|
|
||||||
QVector<QVector<QSharedPointer<Texture> > > _dilatedTextures;
|
QVector<QVector<QSharedPointer<Texture>>> _dilatedTextures;
|
||||||
|
|
||||||
QVector<float> _blendedBlendshapeCoefficients;
|
QVector<float> _blendedBlendshapeCoefficients;
|
||||||
int _blendNumber;
|
int _blendNumber;
|
||||||
|
|
|
@ -31,7 +31,7 @@ int SoftAttachmentModel::getJointIndexOverride(int i) const {
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
// use the _rigOverride matrices instead of the Model::_rig
|
// use the _rigOverride matrices instead of the Model::_rig
|
||||||
void SoftAttachmentModel::updateClusterMatrices(bool triggerBlendshapes) {
|
void SoftAttachmentModel::updateClusterMatrices() {
|
||||||
if (!_needsUpdateClusterMatrices) {
|
if (!_needsUpdateClusterMatrices) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ void SoftAttachmentModel::updateClusterMatrices(bool triggerBlendshapes) {
|
||||||
|
|
||||||
// post the blender if we're not currently waiting for one to finish
|
// post the blender if we're not currently waiting for one to finish
|
||||||
auto modelBlender = DependencyManager::get<ModelBlender>();
|
auto modelBlender = DependencyManager::get<ModelBlender>();
|
||||||
if (triggerBlendshapes && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
|
if (_blendedVertexBuffersInitialized && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
|
||||||
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
|
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
|
||||||
modelBlender->noteRequiresBlend(getThisPointer());
|
modelBlender->noteRequiresBlend(getThisPointer());
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
~SoftAttachmentModel();
|
~SoftAttachmentModel();
|
||||||
|
|
||||||
void updateRig(float deltaTime, glm::mat4 parentTransform) override;
|
void updateRig(float deltaTime, glm::mat4 parentTransform) override;
|
||||||
void updateClusterMatrices(bool triggerBlendshapes = true) override;
|
void updateClusterMatrices() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int getJointIndexOverride(int i) const;
|
int getJointIndexOverride(int i) const;
|
||||||
|
|
Loading…
Reference in a new issue