Must now register with set_transform_notify() to get NOTIFICATION_TRANSFORM_CHANGED

This commit is contained in:
Juan Linietsky 2017-01-12 20:35:46 -03:00
parent da477b76a9
commit a2903fc51d
26 changed files with 65 additions and 7 deletions

View File

@ -1831,6 +1831,7 @@ GridMap::GridMap() {
use_baked_light=false; use_baked_light=false;
navigation = NULL; navigation = NULL;
set_notify_transform(true);
} }

View File

@ -713,5 +713,6 @@ Camera2D::Camera2D() {
v_drag_enabled=true; v_drag_enabled=true;
h_ofs=0; h_ofs=0;
v_ofs=0; v_ofs=0;
set_notify_transform(true);
} }

View File

@ -769,7 +769,7 @@ void CanvasItem::_notify_transform(CanvasItem *p_node) {
p_node->global_invalid=true; p_node->global_invalid=true;
if (!p_node->xform_change.in_list()) { if (notify_transform && !p_node->xform_change.in_list()) {
if (!p_node->block_transform_notify) { if (!p_node->block_transform_notify) {
if (p_node->is_inside_tree()) if (p_node->is_inside_tree())
get_tree()->xform_change_list.add(&p_node->xform_change); get_tree()->xform_change_list.add(&p_node->xform_change);
@ -997,6 +997,12 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(_MD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material); ClassDB::bind_method(_MD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material);
ClassDB::bind_method(_MD("get_use_parent_material"),&CanvasItem::get_use_parent_material); ClassDB::bind_method(_MD("get_use_parent_material"),&CanvasItem::get_use_parent_material);
ClassDB::bind_method(_MD("set_notify_local_transform","enable"),&CanvasItem::set_notify_local_transform);
ClassDB::bind_method(_MD("is_local_transform_notification_enabled"),&CanvasItem::is_local_transform_notification_enabled);
ClassDB::bind_method(_MD("set_notify_transform","enable"),&CanvasItem::set_notify_transform);
ClassDB::bind_method(_MD("is_transform_notification_enabled"),&CanvasItem::is_transform_notification_enabled);
ClassDB::bind_method(_MD("make_canvas_pos_local","screen_point"), ClassDB::bind_method(_MD("make_canvas_pos_local","screen_point"),
&CanvasItem::make_canvas_pos_local); &CanvasItem::make_canvas_pos_local);
ClassDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local); ClassDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local);
@ -1081,6 +1087,15 @@ bool CanvasItem::is_local_transform_notification_enabled() const {
return notify_local_transform; return notify_local_transform;
} }
void CanvasItem::set_notify_transform(bool p_enable) {
notify_transform=p_enable;
}
bool CanvasItem::is_transform_notification_enabled() const {
return notify_transform;
}
int CanvasItem::get_canvas_layer() const { int CanvasItem::get_canvas_layer() const {
if (canvas_layer) if (canvas_layer)
@ -1118,12 +1133,13 @@ CanvasItem::CanvasItem() : xform_change(this) {
first_draw=false; first_draw=false;
drawing=false; drawing=false;
behind=false; behind=false;
block_transform_notify=false; block_transform_notify=false;
// viewport=NULL; // viewport=NULL;
canvas_layer=NULL; canvas_layer=NULL;
use_parent_material=false; use_parent_material=false;
global_invalid=true; global_invalid=true;
notify_local_transform=false; notify_local_transform=false;
notify_transform=false;
light_mask=1; light_mask=1;
C=NULL; C=NULL;

View File

@ -117,6 +117,7 @@ private:
bool behind; bool behind;
bool use_parent_material; bool use_parent_material;
bool notify_local_transform; bool notify_local_transform;
bool notify_transform;
Ref<CanvasItemMaterial> material; Ref<CanvasItemMaterial> material;
@ -256,6 +257,9 @@ public:
void set_notify_local_transform(bool p_enable); void set_notify_local_transform(bool p_enable);
bool is_local_transform_notification_enabled() const; bool is_local_transform_notification_enabled() const;
void set_notify_transform(bool p_enable);
bool is_transform_notification_enabled() const;
int get_canvas_layer() const; int get_canvas_layer() const;
CanvasItem(); CanvasItem();

View File

@ -363,6 +363,7 @@ CollisionObject2D::CollisionObject2D() {
//owner= //owner=
set_notify_transform(true);
} }

View File

@ -482,6 +482,7 @@ Light2D::Light2D() {
shadow_color=Color(0,0,0,0); shadow_color=Color(0,0,0,0);
shadow_filter=SHADOW_FILTER_NONE; shadow_filter=SHADOW_FILTER_NONE;
set_notify_transform(true);
} }
Light2D::~Light2D() { Light2D::~Light2D() {

View File

@ -242,6 +242,7 @@ LightOccluder2D::LightOccluder2D() {
occluder=VS::get_singleton()->canvas_light_occluder_create(); occluder=VS::get_singleton()->canvas_light_occluder_create();
mask=1; mask=1;
set_notify_transform(true);
} }
LightOccluder2D::~LightOccluder2D() { LightOccluder2D::~LightOccluder2D() {

View File

@ -497,5 +497,6 @@ NavigationPolygonInstance::NavigationPolygonInstance() {
navigation=NULL; navigation=NULL;
nav_id=-1; nav_id=-1;
enabled=true; enabled=true;
set_notify_transform(true);
} }

View File

@ -127,7 +127,7 @@ void RemoteTransform2D::_bind_methods() {
RemoteTransform2D::RemoteTransform2D() { RemoteTransform2D::RemoteTransform2D() {
cache=0; cache=0;
set_notify_transform(true);
} }

View File

@ -116,7 +116,7 @@ SoundPlayer2D::SoundPlayer2D() {
params[PARAM_ATTENUATION_MAX_DISTANCE]=2048; params[PARAM_ATTENUATION_MAX_DISTANCE]=2048;
params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good) params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
set_notify_transform(true);
} }
SoundPlayer2D::~SoundPlayer2D() { SoundPlayer2D::~SoundPlayer2D() {

View File

@ -1321,6 +1321,7 @@ TileMap::TileMap() {
fp_adjust=0.00001; fp_adjust=0.00001;
tile_origin=TILE_ORIGIN_TOP_LEFT; tile_origin=TILE_ORIGIN_TOP_LEFT;
set_notify_transform(true);
} }
TileMap::~TileMap() { TileMap::~TileMap() {

View File

@ -145,6 +145,7 @@ void VisibilityNotifier2D::_bind_methods(){
VisibilityNotifier2D::VisibilityNotifier2D() { VisibilityNotifier2D::VisibilityNotifier2D() {
rect=Rect2(-10,-10,20,20); rect=Rect2(-10,-10,20,20);
set_notify_transform(true);
} }

View File

@ -678,6 +678,7 @@ Camera::Camera() {
h_offset=0; h_offset=0;
VisualServer::get_singleton()->camera_set_cull_mask(camera,layers); VisualServer::get_singleton()->camera_set_cull_mask(camera,layers);
//active=false; //active=false;
set_notify_transform(true);
} }

View File

@ -360,7 +360,7 @@ CollisionObject::CollisionObject() {
capture_input_on_drag=false; capture_input_on_drag=false;
ray_pickable=true; ray_pickable=true;
set_notify_transform(true);
//owner= //owner=
//set_transform_notify(true); //set_transform_notify(true);

View File

@ -156,6 +156,7 @@ Listener::Listener() {
current=false; current=false;
force_change=false; force_change=false;
set_notify_transform(true);
//active=false; //active=false;
} }

View File

@ -410,5 +410,6 @@ NavigationMeshInstance::NavigationMeshInstance() {
navigation=NULL; navigation=NULL;
nav_id=-1; nav_id=-1;
enabled=true; enabled=true;
set_notify_transform(true);
} }

View File

@ -195,6 +195,7 @@ Joint::Joint() {
exclude_from_collision=true; exclude_from_collision=true;
solver_priority=1; solver_priority=1;
set_notify_transform(true);
} }

View File

@ -190,6 +190,7 @@ ProximityGroup::ProximityGroup() {
dispatch_mode = MODE_PROXY; dispatch_mode = MODE_PROXY;
grid_radius = Vector3(1, 1, 1); grid_radius = Vector3(1, 1, 1);
set_notify_transform(true);
}; };

View File

@ -127,6 +127,7 @@ void RemoteTransform::_bind_methods() {
RemoteTransform::RemoteTransform() { RemoteTransform::RemoteTransform() {
cache=0; cache=0;
set_notify_transform(true);
} }

View File

@ -216,6 +216,7 @@ Room::Room() {
level=0; level=0;
} }

View File

@ -74,7 +74,7 @@ SpatialGizmo::SpatialGizmo() {
void Spatial::_notify_dirty() { void Spatial::_notify_dirty() {
if (!data.ignore_notification && !xform_change.in_list()) { if (data.notify_transform && !data.ignore_notification && !xform_change.in_list()) {
get_tree()->xform_change_list.add(&xform_change); get_tree()->xform_change_list.add(&xform_change);
} }
@ -108,7 +108,7 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) {
} }
if (!data.ignore_notification && !xform_change.in_list()) { if (data.notify_transform && !data.ignore_notification && !xform_change.in_list()) {
get_tree()->xform_change_list.add(&xform_change); get_tree()->xform_change_list.add(&xform_change);
@ -736,6 +736,14 @@ void Spatial::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, con
} }
void Spatial::set_notify_transform(bool p_enable) {
data.notify_transform=p_enable;
}
bool Spatial::is_transform_notification_enabled() const {
return data.notify_transform;
}
void Spatial::set_notify_local_transform(bool p_enable) { void Spatial::set_notify_local_transform(bool p_enable) {
data.notify_local_transform=p_enable; data.notify_local_transform=p_enable;
} }
@ -791,6 +799,9 @@ void Spatial::_bind_methods() {
ClassDB::bind_method(_MD("set_notify_local_transform","enable"), &Spatial::set_notify_local_transform); ClassDB::bind_method(_MD("set_notify_local_transform","enable"), &Spatial::set_notify_local_transform);
ClassDB::bind_method(_MD("is_local_transform_notification_enabled"), &Spatial::is_local_transform_notification_enabled); ClassDB::bind_method(_MD("is_local_transform_notification_enabled"), &Spatial::is_local_transform_notification_enabled);
ClassDB::bind_method(_MD("set_notify_transform","enable"), &Spatial::set_notify_transform);
ClassDB::bind_method(_MD("is_transform_notification_enabled"), &Spatial::is_transform_notification_enabled);
void rotate(const Vector3& p_normal,float p_radians); void rotate(const Vector3& p_normal,float p_radians);
void rotate_x(float p_radians); void rotate_x(float p_radians);
void rotate_y(float p_radians); void rotate_y(float p_radians);
@ -848,11 +859,13 @@ Spatial::Spatial() : xform_change(this)
data.viewport=NULL; data.viewport=NULL;
data.inside_world=false; data.inside_world=false;
data.visible=true; data.visible=true;
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
data.gizmo_disabled=false; data.gizmo_disabled=false;
data.gizmo_dirty=false; data.gizmo_dirty=false;
#endif #endif
data.notify_local_transform=false; data.notify_local_transform=false;
data.notify_transform=false;
data.parent=NULL; data.parent=NULL;
data.C=NULL; data.C=NULL;

View File

@ -92,6 +92,7 @@ class Spatial : public Node {
bool ignore_notification; bool ignore_notification;
bool notify_local_transform; bool notify_local_transform;
bool notify_transform;
bool visible; bool visible;
@ -184,6 +185,9 @@ public:
void look_at(const Vector3& p_target, const Vector3& p_up_normal); void look_at(const Vector3& p_target, const Vector3& p_up_normal);
void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal); void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
void set_notify_transform(bool p_enable);
bool is_transform_notification_enabled() const;
void set_notify_local_transform(bool p_enable); void set_notify_local_transform(bool p_enable);
bool is_local_transform_notification_enabled() const; bool is_local_transform_notification_enabled() const;

View File

@ -125,6 +125,7 @@ SpatialPlayer::SpatialPlayer() {
params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good) params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
params[PARAM_EMISSION_CONE_DEGREES]=180.0; //cone disabled params[PARAM_EMISSION_CONE_DEGREES]=180.0; //cone disabled
params[PARAM_EMISSION_CONE_ATTENUATION_DB]=-6.0; //minus 6 db attenuation params[PARAM_EMISSION_CONE_ATTENUATION_DB]=-6.0; //minus 6 db attenuation
set_notify_transform(true);
} }

View File

@ -125,6 +125,7 @@ void VisibilityNotifier::_bind_methods(){
VisibilityNotifier::VisibilityNotifier() { VisibilityNotifier::VisibilityNotifier() {
aabb=Rect3(Vector3(-1,-1,-1),Vector3(2,2,2)); aabb=Rect3(Vector3(-1,-1,-1),Vector3(2,2,2));
set_notify_transform(true);
} }

View File

@ -162,6 +162,7 @@ VisualInstance::VisualInstance()
instance = VisualServer::get_singleton()->instance_create(); instance = VisualServer::get_singleton()->instance_create();
VisualServer::get_singleton()->instance_attach_object_instance_ID( instance, get_instance_ID() ); VisualServer::get_singleton()->instance_attach_object_instance_ID( instance, get_instance_ID() );
layers=1; layers=1;
set_notify_transform(true);
} }

View File

@ -1384,6 +1384,8 @@ String Node::_generate_serial_child_name(Node *p_child) {
if (name=="") { if (name=="") {
name = p_child->get_class(); name = p_child->get_class();
/* this is probably too slow to use here, should check alternatives
*
// Adjust casing according to project setting. The current type name is expected to be in PascalCase. // Adjust casing according to project setting. The current type name is expected to be in PascalCase.
switch (Globals::get_singleton()->get("node/name_casing").operator int()) { switch (Globals::get_singleton()->get("node/name_casing").operator int()) {
case NAME_CASING_PASCAL_CASE: case NAME_CASING_PASCAL_CASE:
@ -1395,6 +1397,7 @@ String Node::_generate_serial_child_name(Node *p_child) {
name = name.camelcase_to_underscore(true); name = name.camelcase_to_underscore(true);
break; break;
} }
*/
} }
// Extract trailing number // Extract trailing number