Skip to content

Batching modifications and resizing channels #1

@popcron

Description

@popcron

currently, the API for Mesh.Collection<T> increments the version of the mesh whenever any of this functions are used, or properties or indexers. in the case of doing the following every frame, it's very inefficient:

float x = MathF.Sin(time);
float y = MathF.Cos(time);
Mesh.Collection<Vector3> positions = mesh.GetPositions();
positions[0] = new(x + 0, y + 0, 0);
positions[1] = new(x + 1, y + 0, 0);
positions[2] = new(x + 1, y + 1, 0);
positions[3] = new(x + 0, y + 1, 0);

when instead it could be chunked. not sure how exactly, but perhaps this could be done by fetching a temporary view of the mesh, updating that then submitting it:

Mesh mesh = ...
Mesh.Modification changes = mesh.BeginChanges();
changes[0].position = new(x + 0, y + 0, 0);
changes[1].position = new(x + 1, y + 0, 0);
changes[2].position = new(x + 1, y + 1, 0);
changes[3].position = new(x + 0, y + 1, 0);
mesh.SubmitChanges(changes);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions