SegsEngine icon indicating copy to clipboard operation
SegsEngine copied to clipboard

Reduce usage of Dictionary classes around the codebase.

Open nemerle opened this issue 5 years ago • 0 comments

Many classes return Dictionaries instead of more specific structs:

Dictionary PhysicsDirectSpaceState3D::_intersect_ray
...
    Dictionary d;
    d["position"] = inters.position;
    d["normal"] = inters.normal;
    d["collider_id"] = Variant::from(inters.collider_id);
    d["collider"] = Variant(inters.collider);
    d["shape"] = inters.shape;
    d["rid"] = inters.rid;

    return d;
}

this could be very well be replaced by something like:

struct IntersectResult {
Vector3 position;
Vector3 normal;
ObjectID collider_id;
Object *collider;
int shape;
RID rid;
};
IntersectResult PhysicsDirectSpaceState3D::_intersect_ray(...)

and MethodBinder::bind_method would need to handle decoding/encoding such structs.

The two main issues are caused by bound methods:

  • Some invocations are queued for later execution ( thus their arguments need to be serialized, and return value deserialized ).
  • The script language inter-op does not handle passing generic 'structs'.

nemerle avatar Oct 27 '20 14:10 nemerle