Merge pull request #54899 from clayjohn/MultiMesh-update

This commit is contained in:
Rémi Verschelde 2021-11-22 08:30:49 +01:00 committed by GitHub
commit 86fd7da7a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -29,6 +29,7 @@
/*************************************************************************/
#include "multimesh_instance_2d.h"
#include "core/core_string_names.h"
void MultiMeshInstance2D::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
@ -56,7 +57,16 @@ void MultiMeshInstance2D::_bind_methods() {
}
void MultiMeshInstance2D::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
// Cleanup previous connection if any.
if (multimesh.is_valid()) {
multimesh->disconnect(CoreStringNames::get_singleton()->changed, this, "update");
}
multimesh = p_multimesh;
// Connect to the multimesh so the AABB can update when instance transforms are changed.
if (multimesh.is_valid()) {
multimesh->connect(CoreStringNames::get_singleton()->changed, this, "update");
}
update();
}

View File

@ -29,6 +29,7 @@
/*************************************************************************/
#include "multimesh.h"
#include "servers/visual_server.h"
void MultiMesh::_set_transform_array(const PoolVector<Vector3> &p_array) {
@ -225,6 +226,7 @@ void MultiMesh::set_instance_transform(int p_instance, const Transform &p_transf
void MultiMesh::set_instance_transform_2d(int p_instance, const Transform2D &p_transform) {
VisualServer::get_singleton()->multimesh_instance_set_transform_2d(multimesh, p_instance, p_transform);
emit_changed();
}
Transform MultiMesh::get_instance_transform(int p_instance) const {