Skip to content

[Suggestion] Chunk Materials #14

@Ayliroe

Description

@Ayliroe

Here's an implementation I found working you can add to your tutorial:

  • ChunkBase.h:
    image
    (A blueprint-accessible array for materials, plus arrays for the material struct and vertices instead of single values)

  • ChunkBase.cpp:
    image
    (On clearing, empty the arrays then refresh using the total amount of materials, not blocks)

  • NaiveChunk.cpp, in GenerateMesh():
    image
    (Get the material for the current block's face, minus 2 to skip null and air enums, clamp as a safety, then pass it to CreateFace() )

  • NaiveChunk.cpp, in CreateFace():
    image
    (Switch all mesh structs and the vertex int to the new arrays)

  • GreedyChunk.cpp, GenerateMesh():
    image
    (Same as NaiveChunk, but using CurrentMask.Block for the face's material)

  • ApplyMesh():
    image
    (First clear all previous sections, then generate a new one for each material on the chunk)

Basically the same code as before, but generates one unique section for each different block material. Straightforward to scale-up (just add materials to the array) and supports both naive/greedy meshing. Maybe you had something in mind too of the like.

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