Changeset View
Changeset View
Standalone View
Standalone View
tests/python/modules/mesh_test.py
| Context not available. | |||||
| return "Modifier: " + self.modifier_name + " of type " + self.modifier_type + \ | return "Modifier: " + self.modifier_name + " of type " + self.modifier_type + \ | ||||
| " with parameters: " + str(self.modifier_parameters) | " with parameters: " + str(self.modifier_parameters) | ||||
| class PhysicsSpec: | class PhysicsSpec: | ||||
| """ | """ | ||||
| Holds one modifier and its parameters. | Holds one modifier and its parameters. | ||||
brecht: modifier -> physics modifier | |||||
| """ | """ | ||||
| def __init__(self, modifier_name: str, modifier_type: str, modifier_parameters: dict,frame_end:int): | def __init__(self, modifier_name: str, modifier_type: str, modifier_parameters: dict, frame_end: int): | ||||
| """ | """ | ||||
| Constructs a physics spec. | Constructs a physics spec. | ||||
| :param modifier_name: str - name of object modifier, e.g. "Cloth" | :param modifier_name: str - name of object modifier, e.g. "Cloth" | ||||
| Context not available. | |||||
| def __str__(self): | def __str__(self): | ||||
| return "Modifier: " + self.modifier_name + " of type " + self.modifier_type + \ | return "Modifier: " + self.modifier_name + " of type " + self.modifier_type + \ | ||||
Done Inline Actionsframe_number -> frame_end brecht: `frame_number` -> `frame_end` | |||||
Done Inline ActionsModifier -> Physics Modifier brecht: Modifier -> Physics Modifier | |||||
| " with parameters: " + str(self.modifier_parameters) + " with frame number: "+str(self.frame_number) | " with parameters: " + str(self.modifier_parameters) + " with frame end: " + str(self.frame_end) | ||||
| class OperatorSpec: | class OperatorSpec: | ||||
| """ | """ | ||||
| Context not available. | |||||
| bpy.ops.object.modifier_apply(modifier=modifier_spec.modifier_name) | bpy.ops.object.modifier_apply(modifier=modifier_spec.modifier_name) | ||||
| def bake_current_simulation(self,obj,test_mod_type,test_mod_name,frame_end): | def bake_current_simulation(self, obj, test_mod_type, test_mod_name, frame_end): | ||||
Done Inline ActionsCode style: no empty line right after def line. brecht: Code style: no empty line right after `def` line. | |||||
| for scene in bpy.data.scenes: | for scene in bpy.data.scenes: | ||||
Done Inline ActionsTwo empty lines still here. brecht: Two empty lines still here. | |||||
| Context not available. | |||||
| break | break | ||||
| def _apply_physics_settings(self, test_object, physics_spec: PhysicsSpec): | def _apply_physics_settings(self, test_object, physics_spec: PhysicsSpec): | ||||
| """ | |||||
| Apply Physics settings to test objects. | |||||
Done Inline ActionsAvoid using operators when possible, this can probably be scene.frame_set or similar? It's not even clear to me what this line does, which frame is it supposed to jump to? brecht: Avoid using operators when possible, this can probably be `scene.frame_set` or similar?
It's… | |||||
| bpy.ops.screen.frame_jump(end=False) | """ | ||||
| scene = bpy.context.scene | |||||
| scene.frame_set(1) | |||||
| modifier = test_object.modifiers.new(physics_spec.modifier_name, | modifier = test_object.modifiers.new(physics_spec.modifier_name, | ||||
| physics_spec.modifier_type) | physics_spec.modifier_type) | ||||
| physics_setting = modifier.settings | physics_setting = modifier.settings | ||||
Done Inline ActionsCode style: use only one empty line as separator inside functions. brecht: Code style: use only one empty line as separator inside functions. | |||||
| Context not available. | |||||
| format(physics_spec.modifier_name, physics_spec.modifier_type)) | format(physics_spec.modifier_name, physics_spec.modifier_type)) | ||||
| for param_name in physics_spec.modifier_parameters: | for param_name in physics_spec.modifier_parameters: | ||||
| try: | try: | ||||
| setattr(physics_setting, param_name, physics_spec.modifier_parameters[param_name]) | setattr(physics_setting, param_name, physics_spec.modifier_parameters[param_name]) | ||||
| if self.verbose: | if self.verbose: | ||||
| print("\t set parameter '{}' with value '{}'". | print("\t set parameter '{}' with value '{}'". | ||||
| format(param_name, physics_spec.modifier_parameters[param_name])) | format(param_name, physics_spec.modifier_parameters[param_name])) | ||||
| Context not available. | |||||
| bpy.ops.screen.frame_offset(delta=(physics_spec.frame_end+1)) | bpy.ops.screen.frame_offset(delta=(physics_spec.frame_end+1)) | ||||
Done Inline ActionsThis can also just call scene.frame_set? brecht: This can also just call `scene.frame_set`? | |||||
| self.bake_current_simulation(test_object,physics_spec.modifier_type,physics_spec.modifier_name, physics_spec.frame_end) | self.bake_current_simulation(test_object, physics_spec.modifier_type, physics_spec.modifier_name, physics_spec.frame_end) | ||||
Not Done Inline ActionsEasier to just pass the physics_spec entirely to this function. brecht: Easier to just pass the `physics_spec` entirely to this function. | |||||
Done Inline ActionsAccessing using physics_spec feels unnecessarily long. calra: Accessing using `physics_spec` feels unnecessarily long. | |||||
| if self.apply_modifier: | if self.apply_modifier: | ||||
| bpy.ops.object.modifier_apply(modifier=physics_spec.modifier_name) | bpy.ops.object.modifier_apply(modifier=physics_spec.modifier_name) | ||||
| Context not available. | |||||
modifier -> physics modifier