Skip to content

Make colors of polygons reflect the color of the source object. #56

Open

Description

@madhephaestus

It would be nice to have the color of a polygon withing a CSG object preserve the color of its source object through difference and union operations.

The storage of the Color needs to be moved from the storage object that is synced at the end of an op, and therefor obliterates one of the colors and replaces it with a single color.

@breiler attempted to fix the polygon color issue here: #54 but some operations still sync the storage and break the color.

To so this we need to make a Color object in the CSG, and pass a reference to it to the polygons when the color is set, but not when the CSG operations is called.

Activity

  1. breiler commented on Aug 12, 2024

    @breiler

    It is getting there, I did a local build of #58 and it will now retain the colors of the polygons on unions 🥳:

    image

    There is still some work to be done on difference operations, for instance in this case I would expect the cube to still be blue with one red face (as the cube used for cutting one side of the cube was red):

    CSG cube1 = new Cube(1)
            .toCSG()
            .move(-0.5, 0, 0)
            .setColor(Color.BLUE);
    
    CSG cube2 = new Cube(1)
            .toCSG()
            .move(0.49, 0, 0)
            .setColor(Color.RED);
    
    model = cube1.difference(cube2).scale(0.4);

    But instead I got this:

    Screencast.from.2024-08-12.18-57-00.webm

    I'll see if I can figure this out tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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