Skip to content

[Prefabs] Modifier implementation #5#597

Open
EulalieCoevoet wants to merge 1 commit intosofa-framework:25_04_work_on_new_prefabsfrom
EulalieCoevoet:dev_prefabs
Open

[Prefabs] Modifier implementation #5#597
EulalieCoevoet wants to merge 1 commit intosofa-framework:25_04_work_on_new_prefabsfrom
EulalieCoevoet:dev_prefabs

Conversation

@EulalieCoevoet
Copy link
Contributor

@EulalieCoevoet EulalieCoevoet commented Mar 5, 2026

Proposition:
Introduce the create method to instantiate a Node, Entity, EntityModifier or Component(?) without adding it to the scene graph.
Thus to apply an EntityModifier to entities, we need to first create it and then call the apply method.
Adding an EntityModifier with the method add should raise an error.

In case of a EntityModifier:

  • create: instantiate the object and store its creator
  • apply: add the modifier to the scene graph, in creator\Modifiers, and in or near the modified entities depending on the modifications applied. And apply the method modifier.

Exemple:

See examples/stlib/EulalieScene.py.

def createScene(rootnode):

    simulation = addSimulationSettings(rootnode) # adds the default header (with solvers)

    cube1 = simulation.add(Entity, parameters=EntityParameters(name = "FixedCube"))
    cube2 = simulation.add(Entity, parameters=EntityParameters(name = "FallingCube"))
    
    simulation.create(SingleEntityModifier, parameters=FixingModifierParameters()).apply(entity=cube1) # one line example
image

In this PR:

  • Implementation of the create method
  • Implementation of the BaseEntityModifier, SingleEntityModifier, and FixingModifierParameters
  • Implementation of the discussed addSimulationSettings and the methods to register the required solvers.
  • Unifies the writing of dataclasses: class parameters instead of changing the signature of the __init__ method
  • Makes the default Entity a rigid cube
  • Removes the getParameters in the entities class as I feel like we don't use it and it can be confusing to have different implementations of the same thing. Meaning, I prefer to always do:
    from stlib.visual import Visual, VisualParameters
    def createScene(rootnode):
        rootnode.add(Visual, parameters=VisualParameters())

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant