Skip to content

Why do chains don't use B2ShapeId? #63

@reynarzz

Description

@reynarzz

At the moment, when you create a chain using B2Shapes.b2CreateChain, it returns a B2ChainId instead of a B2ShapeId. This not only breaks the api's convention but also makes it difficult to create proper abstractions around shape creation.
Since both structs share the same structure, using B2ShapeId instead of B2ChainId for chains will "just work."

These two are essentially the same:

public readonly struct B2ChainId
{
    public readonly int index1;
    public readonly ushort world0;
    public readonly ushort generation;

    public B2ChainId(int index1, ushort world0, ushort generation)
    {
        this.index1 = index1;
        this.world0 = world0;
        this.generation = generation;
    }
}

And

public readonly struct B2ShapeId
{
    public readonly int index1;
    public readonly ushort world0;
    public readonly ushort generation;

    public B2ShapeId(int index1, ushort world0, ushort generation)
    {
        this.index1 = index1;
        this.world0 = world0;
        this.generation = generation;
    }


    public override string ToString()
    {
        return $"(i:{index1}, w:{world0}, g:{generation})";
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions