Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store ObjectID instead of Object * for Shape Owners #57182

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scene/2d/collision_object_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ uint32_t CollisionObject2D::create_shape_owner(Object *p_owner) {
id = shapes.back()->key() + 1;
}

sd.owner = p_owner;
sd.owner_id = p_owner ? p_owner->get_instance_id() : ObjectID();

shapes[id] = sd;

Expand Down Expand Up @@ -382,7 +382,7 @@ Transform2D CollisionObject2D::shape_owner_get_transform(uint32_t p_owner) const
Object *CollisionObject2D::shape_owner_get_owner(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr);

return shapes[p_owner].owner;
return ObjectDB::get_instance(shapes[p_owner].owner_id);
}

void CollisionObject2D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2D> &p_shape) {
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/collision_object_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CollisionObject2D : public Node2D {
PhysicsServer2D::BodyMode body_mode = PhysicsServer2D::BODY_MODE_STATIC;

struct ShapeData {
Object *owner = nullptr;
ObjectID owner_id;
Transform2D xform;
struct Shape {
Ref<Shape2D> shape;
Expand Down
4 changes: 2 additions & 2 deletions scene/3d/collision_object_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ uint32_t CollisionObject3D::create_shape_owner(Object *p_owner) {
id = shapes.back()->key() + 1;
}

sd.owner = p_owner;
sd.owner_id = p_owner ? p_owner->get_instance_id() : ObjectID();

shapes[id] = sd;

Expand Down Expand Up @@ -563,7 +563,7 @@ Transform3D CollisionObject3D::shape_owner_get_transform(uint32_t p_owner) const
Object *CollisionObject3D::shape_owner_get_owner(uint32_t p_owner) const {
ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr);

return shapes[p_owner].owner;
return ObjectDB::get_instance(shapes[p_owner].owner_id);
}

void CollisionObject3D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape3D> &p_shape) {
Expand Down
2 changes: 1 addition & 1 deletion scene/3d/collision_object_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CollisionObject3D : public Node3D {
PhysicsServer3D::BodyMode body_mode = PhysicsServer3D::BODY_MODE_STATIC;

struct ShapeData {
Object *owner = nullptr;
ObjectID owner_id;
Transform3D xform;
struct ShapeBase {
RID debug_shape;
Expand Down