Update CanvasItem when MultiMesh instance transform changes
(cherry picked from commit b54d4a93be
)
This commit is contained in:
parent
1b3c02eba6
commit
5e95d317e6
2 changed files with 12 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "multimesh_instance_2d.h"
|
#include "multimesh_instance_2d.h"
|
||||||
|
#include "core/core_string_names.h"
|
||||||
|
|
||||||
void MultiMeshInstance2D::_notification(int p_what) {
|
void MultiMeshInstance2D::_notification(int p_what) {
|
||||||
if (p_what == NOTIFICATION_DRAW) {
|
if (p_what == NOTIFICATION_DRAW) {
|
||||||
|
@ -56,7 +57,16 @@ void MultiMeshInstance2D::_bind_methods() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiMeshInstance2D::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
|
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;
|
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();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "multimesh.h"
|
#include "multimesh.h"
|
||||||
|
|
||||||
#include "servers/visual_server.h"
|
#include "servers/visual_server.h"
|
||||||
|
|
||||||
void MultiMesh::_set_transform_array(const PoolVector<Vector3> &p_array) {
|
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) {
|
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);
|
VisualServer::get_singleton()->multimesh_instance_set_transform_2d(multimesh, p_instance, p_transform);
|
||||||
|
emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform MultiMesh::get_instance_transform(int p_instance) const {
|
Transform MultiMesh::get_instance_transform(int p_instance) const {
|
||||||
|
|
Loading…
Reference in a new issue