예제 #1
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;

	}
}
예제 #2
0
CollisionShape2D::CollisionShape2D() {

    rect=Rect2(-Point2(10,10),Point2(20,20));
    set_notify_local_transform(true);
    trigger=false;
    unparenting = false;
    can_update_body = false;
    update_shape_index=-1;
}
예제 #3
0
CollisionShape::CollisionShape() {

	//indicator = VisualServer::get_singleton()->mesh_create();
	disabled = false;
	debug_shape = NULL;
	parent = NULL;
	owner_id = 0;
	set_notify_local_transform(true);
}
예제 #4
0
CollisionPolygon::CollisionPolygon() {

	aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
	depth = 1.0;
	set_notify_local_transform(true);
	parent = NULL;
	owner_id = 0;
	disabled = false;
}
예제 #5
0
CollisionPolygon2D::CollisionPolygon2D() {

	aabb = Rect2(-10, -10, 20, 20);
	build_mode = BUILD_SOLIDS;
	trigger = false;
	unparenting = false;
	shape_from = -1;
	shape_to = -1;
	can_update_body = false;
	set_notify_local_transform(true);
}