Segs / SegsEngine

The engine that will become the basis for client/editor/server components.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reduce usage of Dictionary classes around the codebase.

nemerle opened this issue · 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'.