Exemple #1
0
void CollisionShape::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {
			unparenting=false;

			//indicator_instance = VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario());
		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {
		//	VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
			if (updating_body) {
				_update_body();
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {
		/*	if (indicator_instance.is_valid()) {
				VisualServer::get_singleton()->free(indicator_instance);
				indicator_instance=RID();
			}*/
		} break;
		case NOTIFICATION_UNPARENTED: {
			unparenting=true;
			if (updating_body)
				_update_body();
		} break;
		case NOTIFICATION_PARENTED: {
			if (updating_body)
				_update_body();
		} break;
	}
}
Exemple #2
0
void CollisionShape::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {
			unparenting=false;
			can_update_body=get_tree()->is_editor_hint();
			set_notify_local_transform(!can_update_body);

			if (get_tree()->is_debugging_collisions_hint()) {
				_create_debug_shape();
			}

			//indicator_instance = VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario());
		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {
		//	VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
			if (can_update_body && updating_body) {
				_update_body();
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {
		/*	if (indicator_instance.is_valid()) {
				VisualServer::get_singleton()->free(indicator_instance);
				indicator_instance=RID();
			}*/
			can_update_body=false;
			set_notify_local_transform(false);
			if (debug_shape) {
				debug_shape->queue_delete();
				debug_shape=NULL;
			}
		} break;
		case NOTIFICATION_UNPARENTED: {
			unparenting=true;
			if (can_update_body && updating_body)
				_update_body();
		} break;
		case NOTIFICATION_PARENTED: {
			if (can_update_body && updating_body)
				_update_body();
		} break;
		case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {

			if (!can_update_body && update_shape_index>=0) {

				CollisionObject *co = get_parent()->cast_to<CollisionObject>();
				if (co) {
					co->set_shape_transform(update_shape_index,get_transform());
				}
			}

		} break;

	}
}
Exemple #3
0
void CollisionShape::set_shape(const Ref<Shape> &p_shape) {

	if (!shape.is_null())
		shape->unregister_owner(this);
	shape=p_shape;
	if (!shape.is_null())
		shape->register_owner(this);
	update_gizmo();
	if (updating_body)
		_update_body();
}
Exemple #4
0
void CollisionShape::set_trigger(bool p_trigger) {

    trigger=p_trigger;
    if (updating_body) {
        _update_body();
    } else if (can_update_body && update_shape_index>=0 && is_inside_tree()){
	    CollisionObject *co = get_parent()->cast_to<CollisionObject>();
	    if (co) {
		    co->set_shape_as_trigger(update_shape_index,p_trigger);
	    }
    }
}
Exemple #5
0
void CollisionShape::set_shape(const Ref<Shape> &p_shape) {

	if (!shape.is_null())
		shape->unregister_owner(this);
	shape = p_shape;
	if (!shape.is_null())
		shape->register_owner(this);
	update_gizmo();
	if (updating_body) {
		_update_body();
	} else if (can_update_body && update_shape_index >= 0 && is_inside_tree()) {
		CollisionObject *co = get_parent()->cast_to<CollisionObject>();
		if (co) {
			co->set_shape(update_shape_index, p_shape);
		}
	}
}
Exemple #6
0
void CollisionShape::set_trigger(bool p_trigger) {

    trigger=p_trigger;
    if (updating_body)
        _update_body();
}