brokkr_kitbash freeze: kit_* refused by the bridge's property setter, the held live mesh kept by a fake user, a dirty frozen part reported and refused at export (cut kit-freeze, fix batch h2)
Answers verdict aetheria-release:verdict:cut-kit-freeze.s1.
- setObjectCustomProperty refuses any name starting with kit_: those properties are brokkr_kitbash's state, so
kit_frozen keeps freeze and thaw as its only writers.
- freeze gives the held live mesh a fake user (marked kit_kept, taken back by the last thaw), so a purge cannot
delete it when kit_frozen is overwritten by hand; thaw's refusal then names the kept meshes no frozen object holds.
- part_report: faces is the live mesh's count, frozen or not; a frozen part adds evaluated {faces}; a frozen part
with a modifier shown again reports dirty (the modifiers) and frozen false. freeze reports faces (live) and
evaluated {faces, volume, nonManifoldEdges}.
- exportGltf with applyModifiers refuses an export that includes a frozen object with a modifier shown.
- Live pins: kitbash_hose freezes a hose and its rebuild is refused; kitbash_assembly pins the setter refusal, the
purge with an overwritten kit_frozen, the dirty report and the export refusal.
- kitbash_assembly and kitbash_faceted print their wall times and keep them out of the result files.
- docs/kitbash.md: the KESTREL wall-time ratio as a range (about 2.7 to 5.7), the Boolean evaluation counts
(1035 against 139) as the stable measure.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
bca5be5af3
commit
d60be15af2
14 changed files with 235 additions and 78 deletions
|
|
@ -33,7 +33,7 @@
|
|||
{"name": "targetObjectName", "type": "string", "required": true, "doc": "the object's name"},
|
||||
{"name": "parentObjectName", "type": "string", "doc": "empty or absent clears the parent"}
|
||||
]},
|
||||
{"name": "setObjectCustomProperty", "doc": "Set one custom property on an object.", "changesScene": true, "editModeSafe": false, "fields": [
|
||||
{"name": "setObjectCustomProperty", "doc": "Set one custom property on an object. Refuses a name starting with kit_: those are brokkr_kitbash's own state, written by its actions.", "changesScene": true, "editModeSafe": false, "fields": [
|
||||
{"name": "targetObjectName", "type": "string", "required": true, "doc": "the object's name"},
|
||||
{"name": "propertyName", "type": "string", "default": "brokkrValue"},
|
||||
{"name": "value", "type": "any", "required": true, "doc": "any JSON value Blender accepts as a property"}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ DEFAULT_DEBUG_MIRROR_ROOT = "//.brokkr/blender-editor-debug"
|
|||
HOST_SNAPSHOT_SCHEMA = "brokkr.blender.host_snapshot.v0"
|
||||
HOST_ACTIONS_FILE = "brokkr_actions.json"
|
||||
HOST_RESULT_LIMIT = 16000 # characters of a host operator's result copied into a receipt
|
||||
KIT_RESERVED = "kit_" # brokkr_kitbash owns every custom property so named: setObjectCustomProperty refuses them
|
||||
KIT_FROZEN = "kit_frozen" # brokkr_kitbash's frozen state (its FROZEN): read here only, to refuse an export that would apply a stack twice
|
||||
COMMAND_INTENT_SCHEMA = "brokkr.blender.command_intent.v0"
|
||||
COMMAND_RECEIPT_SCHEMA = "brokkr.blender.command_receipt.v0"
|
||||
SYNC_SESSION_SCHEMA = "brokkr.sync.session.v0"
|
||||
|
|
@ -944,6 +946,9 @@ class BrokkrBlenderTarget:
|
|||
property_name = command["propertyName"]
|
||||
if property_name.startswith("customProperties."):
|
||||
property_name = property_name[len("customProperties."):]
|
||||
if property_name.startswith(KIT_RESERVED):
|
||||
raise sa.ActionRefused(f"{property_name!r} is brokkr_kitbash's own state ({KIT_RESERVED}*): its actions write it, and a value set "
|
||||
"here would leave the object and the property disagreeing. Use the brokkr_kitbash action; nothing changed.")
|
||||
modifier_name = na.drives_modifier_input(obj, property_name)
|
||||
if modifier_name:
|
||||
return self._receipt(command, "failed", f"{property_name!r} is an input of Geometry Nodes modifier {modifier_name!r}; "
|
||||
|
|
@ -1027,6 +1032,13 @@ class BrokkrBlenderTarget:
|
|||
off_layer = [o.name for o in chosen if o.name not in context.view_layer.objects]
|
||||
if off_layer:
|
||||
raise sa.ActionRefused(f"Selection object is not in the active view layer: {off_layer[0]}")
|
||||
if command["applyModifiers"]:
|
||||
# A frozen object's mesh is already its stack's result: a modifier shown on it again would be applied twice.
|
||||
dirty = sorted(o.name for o in (chosen or context.view_layer.objects.values())
|
||||
if o.get(KIT_FROZEN) is not None and any(m.show_viewport for m in o.modifiers))
|
||||
if dirty:
|
||||
raise sa.ActionRefused(f"{', '.join(dirty)}: frozen (brokkr_kitbash.freeze) with a modifier shown again, so the export would apply "
|
||||
"the stack on top of its own result. Thaw it (brokkr_kitbash.thaw), or hide its modifiers; nothing written.")
|
||||
# The exporter writes into a fresh staging folder beside the target, never onto the output
|
||||
# directory: it may also write a .bin and texture files whose names Brokkr does not choose. Only
|
||||
# after it finishes does every file move into place, each refused if its name is taken, so no
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ from . import core, route
|
|||
KIT, PART, PARAMS = "kit_kit", "kit_part", "kit_params"
|
||||
SOCKET, PARENT_SOCKET, ROLL = "kit_socket", "kit_parent_socket", "kit_roll"
|
||||
FROZEN = "kit_frozen" # on a frozen object: an ID pointer to its live mesh; its presence is the frozen state, freeze sets it and thaw deletes it
|
||||
KEPT = "kit_kept" # on a live mesh a frozen object holds: freeze gave it the fake user that keeps it through a purge, and the last thaw takes it back
|
||||
CLOSE, CLOSE_TO, CLOSE_TO_SOCKET = "kit_close_socket", "kit_close_to", "kit_close_to_socket"
|
||||
HELD = 1e-5 # a connection or a closure holds when its residual is at most this (as RIGID)
|
||||
BEVEL = "Kit Bevel"
|
||||
|
|
@ -351,12 +352,26 @@ def scene_closures(context, report: dict, ends=()) -> list:
|
|||
|
||||
|
||||
def part_report(obj, part, built) -> dict:
|
||||
"""A part as the scene has it. Reads stored properties and matrices only: no modifier is evaluated."""
|
||||
return {"object": obj.name, "kit": part["kit"], "part": part["name"], "params": built.params,
|
||||
"faces": len(obj.data.polygons), "shells": built.shell_count, "bevel": round(built.bevel, 6),
|
||||
"sockets": core.socket_rows(built.sockets, np.array(obj.matrix_world)),
|
||||
"connection": connection_report(obj, part, built), "closure": closure_report(obj, part, built),
|
||||
"frozen": FROZEN in obj}
|
||||
"""A part as the scene has it. Reads stored properties and matrices only: no modifier is evaluated. `faces` is the
|
||||
live mesh's count, frozen or not; a frozen part adds `evaluated`, the count of the frozen mesh it carries. A frozen
|
||||
part with a modifier shown again (by hand: no action does it) is `dirty`, the modifiers named, and not `frozen`:
|
||||
Blender applies them on top of the frozen mesh, so what it shows and exports is not what was frozen."""
|
||||
held = obj.get(FROZEN)
|
||||
report = {"object": obj.name, "kit": part["kit"], "part": part["name"], "params": built.params,
|
||||
"faces": len((held if isinstance(held, bpy.types.Mesh) else obj.data).polygons), "shells": built.shell_count, "bevel": round(built.bevel, 6),
|
||||
"sockets": core.socket_rows(built.sockets, np.array(obj.matrix_world)),
|
||||
"connection": connection_report(obj, part, built), "closure": closure_report(obj, part, built),
|
||||
"frozen": FROZEN in obj and not shown(obj)}
|
||||
if FROZEN in obj:
|
||||
report["evaluated"] = {"faces": len(obj.data.polygons)}
|
||||
if shown(obj):
|
||||
report["dirty"] = shown(obj)
|
||||
return report
|
||||
|
||||
|
||||
def shown(obj) -> list:
|
||||
"""The modifiers Blender evaluates for the object, in a viewport or a render, by name."""
|
||||
return [modifier.name for modifier in obj.modifiers if modifier.show_viewport or modifier.show_render]
|
||||
|
||||
|
||||
def live(obj, doing: str) -> None:
|
||||
|
|
@ -917,11 +932,13 @@ class BROKKR_KITBASH_OT_freeze(PolishOperator):
|
|||
if (index < 0).any(): # faces from a cutter's empty slot: slot 0, as faces from a cutter with no material
|
||||
frozen.polygons.foreach_set("material_index", np.maximum(index, 0))
|
||||
frozen.name = f"{obj.name} frozen"
|
||||
if not obj.data.use_fake_user: # the pointer below is a user too, but a property can be overwritten: the mesh outlives that
|
||||
obj.data.use_fake_user = obj.data[KEPT] = True
|
||||
obj[FROZEN] = obj.data
|
||||
obj.data = frozen
|
||||
for modifier in obj.modifiers:
|
||||
modifier.show_viewport = modifier.show_render = False
|
||||
report.update(frozen=True, **measured(frozen), modifiers=[modifier.name for modifier in obj.modifiers])
|
||||
report.update(frozen=True, faces=len(obj[FROZEN].polygons), evaluated=measured(frozen), modifiers=[modifier.name for modifier in obj.modifiers])
|
||||
report["booleans"] = fitted(report, "booleans", booleans(obj))
|
||||
return report
|
||||
|
||||
|
|
@ -940,9 +957,14 @@ class BROKKR_KITBASH_OT_thaw(PolishOperator):
|
|||
raise Refused(f"{obj.name!r} is not frozen; nothing changed.")
|
||||
held, frozen = obj[FROZEN], obj.data
|
||||
if not isinstance(held, bpy.types.Mesh):
|
||||
raise Refused(f"{obj.name!r} is frozen and the live mesh its {FROZEN} held is gone: there is nothing to thaw to; nothing changed.")
|
||||
kept = sorted(mesh.name for mesh in bpy.data.meshes if KEPT in mesh and not any(other.get(FROZEN) == mesh for other in bpy.data.objects))
|
||||
raise Refused(f"{obj.name!r} is frozen and the live mesh its {FROZEN} held is gone: there is nothing to thaw to"
|
||||
+ (f". Live meshes freeze kept that no frozen object holds: {', '.join(kept)}" if kept else "") + "; nothing changed.")
|
||||
obj.data = held
|
||||
del obj[FROZEN]
|
||||
if KEPT in held and not any(other.get(FROZEN) == held for other in bpy.data.objects):
|
||||
del held[KEPT]
|
||||
held.use_fake_user = False
|
||||
for modifier in obj.modifiers:
|
||||
modifier.show_viewport = modifier.show_render = True
|
||||
if frozen.users == 0:
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@
|
|||
},
|
||||
{
|
||||
"name": "brokkr_kitbash.report",
|
||||
"doc": "Placed kit parts as the scene has them: kit, part, params, faces, shells, each socket's world 4x4, the connection (parent, sockets, roll, residual, holds) and frozen. Evaluates no modifier. Refuses a part scaled in the world: resize with set_params.",
|
||||
"doc": "Placed kit parts as the scene has them: kit, part, params, faces, shells, each socket's world 4x4, the connection (parent, sockets, roll, residual, holds) and frozen. faces counts the live mesh; a frozen part adds evaluated {faces}, and dirty (the modifiers shown again by hand, with frozen false). Evaluates no modifier. Refuses a part scaled in the world: resize with set_params.",
|
||||
"changesScene": false,
|
||||
"editModeSafe": true,
|
||||
"result": "brokkr_mesh_polish_result",
|
||||
|
|
@ -553,7 +553,7 @@
|
|||
},
|
||||
{
|
||||
"name": "brokkr_kitbash.freeze",
|
||||
"doc": "Freeze a mesh object that has modifiers (a kit part, a shell or any mesh) when its cuts are settled: its mesh becomes its evaluated mesh, its live mesh is held by its kit_frozen property, and every modifier stays in the stack, turned off, with its collections and cutters. Blender re-evaluates a live collection Boolean after any removal, hide or mesh read anywhere in the scene; a frozen object costs nothing there. Sockets, connections and report rows stay. set_params, boolean, cut, cut_many, ribs and a shell or hose rebuild refuse a frozen object: thaw it first. Refuses a frozen object, one with no modifiers, one with a modifier already off (named) and one Blender does not evaluate. Reports object (or the part), frozen, faces, volume, nonManifoldEdges, modifiers and booleans.",
|
||||
"doc": "Freeze a mesh object that has modifiers (a kit part, a shell or any mesh) when its cuts are settled: its mesh becomes its evaluated mesh, its live mesh is held by its kit_frozen property, and every modifier stays in the stack, turned off, with its collections and cutters. Blender re-evaluates a live collection Boolean after any removal, hide or mesh read anywhere in the scene; a frozen object costs nothing there. Sockets, connections and report rows stay. set_params, boolean, cut, cut_many, ribs and a shell or hose rebuild refuse a frozen object: thaw it first. Refuses a frozen object, one with no modifiers, one with a modifier already off (named) and one Blender does not evaluate. Reports object (or the part), frozen, faces (the live mesh's), evaluated {faces, volume, nonManifoldEdges}, modifiers and booleans.",
|
||||
"changesScene": true,
|
||||
"editModeSafe": false,
|
||||
"result": "brokkr_mesh_polish_result",
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ Who owns what:
|
|||
- A boolean belongs to its Boolean modifier on the part that is cut.
|
||||
- Whether a cut object is live or frozen belongs to its `kit_frozen` property, which holds the live mesh while
|
||||
the object carries its evaluated one. Only `freeze` sets it, and `thaw`, which deletes it, is its one undo.
|
||||
- Every `kit_*` custom property is the kit's: Brokkr's `setObjectCustomProperty` refuses a name that starts with
|
||||
`kit_`, so each has only the writers named here.
|
||||
|
||||
## A part, end to end
|
||||
|
||||
|
|
@ -339,15 +341,18 @@ sphere under one Exact Boolean of four cutters each), each trigger on an unrelat
|
|||
the plates frozen, 0.004 to 0.014 s (three interleaved repetitions, Blender 5.3 on Starfire).
|
||||
|
||||
**`freeze`** takes any mesh object that has modifiers, a kit part, a shell or a plain mesh. Its mesh becomes its
|
||||
evaluated mesh (named `<object> frozen`), its live mesh is held by an ID-pointer property, `kit_frozen`, so it
|
||||
survives a purge of orphans, and every modifier stays in the stack with its collections, turned off in viewports
|
||||
and renders. Nothing is removed: the cutter objects stay, a cutter placed by `cut` keeps its floor socket and what
|
||||
evaluated mesh (named `<object> frozen`), its live mesh is held by an ID-pointer property, `kit_frozen`, and
|
||||
given a fake user (marked `kit_kept` on the mesh, and taken back by the last `thaw`), so it survives a purge of
|
||||
orphans even if `kit_frozen` is edited by hand, and every modifier stays in the stack with its collections, turned
|
||||
off in viewports and renders. Nothing is removed: the cutter objects stay, a cutter placed by `cut` keeps its floor socket and what
|
||||
is attached to it, and `booleans` still lists what cuts the object. The frozen mesh's material slots are the
|
||||
object's own (an empty one it had included), followed by any a cutter brought; faces a cutter made from an empty
|
||||
slot of its own take the first slot. A frozen kit part keeps `kit_kit`, `kit_part`, `kit_params` and its
|
||||
connections: its sockets are still derived from the params, so `attach`, `detach`, `roll`, `aim`, `reach` and
|
||||
`close` work on it and on what hangs from it. `freeze` reports the part (or `object`), `frozen`, `faces`,
|
||||
`volume`, `nonManifoldEdges`, `modifiers` and `booleans`.
|
||||
`close` work on it and on what hangs from it. `freeze` reports the part (or `object`), `frozen`, `faces` (the live
|
||||
mesh's count, as in every report), `evaluated: {faces, volume, nonManifoldEdges}` (the frozen mesh), `modifiers`
|
||||
and `booleans`. `report` on a frozen part gives `faces`, still the live mesh's, and `evaluated: {faces}`, the
|
||||
frozen mesh's.
|
||||
|
||||
**`thaw`** puts the live mesh back, deletes `kit_frozen`, turns every modifier on and removes the frozen mesh. It
|
||||
evaluates nothing itself; Blender evaluates the object once afterwards, and the thawed object evaluates to the
|
||||
|
|
@ -358,16 +363,22 @@ with "thaw it first": `set_params`, `boolean`, `cut`, `cut_many`, `ribs` from it
|
|||
it, and `freeze`. Derive ribs before freezing a cage. `freeze` also refuses an object with no modifiers, one with a
|
||||
modifier already off in viewports or renders (it names them: `thaw` turns every modifier on, and would not give
|
||||
that stack back), and one Blender does not evaluate. `thaw` refuses an object that is not frozen, and one whose
|
||||
held mesh was removed. What nothing detects: a modifier of a frozen object turned on by hand, and a material
|
||||
assigned to a frozen object, which lands on the frozen mesh and goes at `thaw`. `exportGltf` with `applyModifiers`
|
||||
exports a frozen object's frozen mesh, since its modifiers are off.
|
||||
`kit_frozen` no longer holds a mesh; if a hand edit overwrote it, the refusal names the live meshes freeze kept
|
||||
that no frozen object holds, and setting `kit_frozen` back to that mesh by hand lets `thaw` through.
|
||||
|
||||
A modifier of a frozen object turned on by hand is applied on top of the frozen mesh. `report` shows such a part
|
||||
with `frozen` false and `dirty`, the names of the modifiers shown; it stays refused by the actions above until it
|
||||
is thawed. `exportGltf` with `applyModifiers` exports a frozen object's frozen mesh, since its modifiers are off,
|
||||
and refuses an export that includes a frozen object with a modifier shown in viewports. What nothing detects: a
|
||||
material assigned to a frozen object, which lands on the frozen mesh and goes at `thaw`.
|
||||
|
||||
What it buys on an assembly: KESTREL, an experiment mech of 22 cut shells and blocks, evaluated 1035 Booleans
|
||||
where its cuts need 139 when each finished component was only hidden, and 139 when each was frozen as it was
|
||||
finished; the whole build took 4.5 times as long hidden as frozen (medians of three interleaved pairs, 3.4 to 5.7
|
||||
within a pair, Blender 5.3 on Starfire under other load; an earlier series on a quieter machine read 251.7 s
|
||||
against 51.2 s). In `tests/live/kitbash_assembly.py`, removing an orphan mesh beside three cut tanks costs 1.05 s
|
||||
with them live and 0.0023 s with them frozen.
|
||||
finished. The evaluation counts are the stable measure: they repeat exactly. Wall time follows the machine's
|
||||
load: the whole build took about 2.7 to 5.7 times as long hidden as frozen across two series of three interleaved
|
||||
pairs (Blender 5.3 on Starfire under other load; 133 to 149 s against 32 to 54 s in the later one). In
|
||||
`tests/live/kitbash_assembly.py`, removing an orphan mesh beside three cut tanks costs about 1 s with them live
|
||||
and about 0.002 s with them frozen.
|
||||
|
||||
## Making a shell
|
||||
|
||||
|
|
@ -819,7 +830,7 @@ vertices overflow.
|
|||
| `brokkr_kitbash.describe` | `kit` (default `mechanical`), `part` (default: all) | Parts with their params (type, min, max, default, doc) and sockets in the part frame at default params. Changes nothing. |
|
||||
| `brokkr_kitbash.place_part` | `kit`, `part`, `object_name`, `params` | A new mesh object at the origin: the part's mesh, a `Kit Bevel` modifier when the part has a bevel, and the three ID properties. Refuses a name an object already has. |
|
||||
| `brokkr_kitbash.set_params` | `object_name`, `params` | Overlays `params` on the stored ones and rebuilds the mesh in the same datablock: modifiers and material slots stay, and the Bevel width follows. Per-face materials are carried by shape: each shape of the part keeps the material most of its faces had, whatever the new face count. Seats the part and the parts attached to it again; refuses a change that breaks a connection or a closure's mate, and a frozen part. Reports the part and `closures`, every closure in the scene as `{part, to, holds}`: its own first, then the broken, then the rest; rows that would not fit a receipt are left off the end and counted in `closuresOmitted`. Each closure in the scene adds a few milliseconds (both its parts are built again to find their sockets). |
|
||||
| `brokkr_kitbash.report` | `object_name` (default: every kit part) | Each part as the scene has it: kit, part, params, faces, shells, each socket's world frame, `connection`, `closure` and `frozen`. Changes nothing and evaluates no modifier. |
|
||||
| `brokkr_kitbash.report` | `object_name` (default: every kit part) | Each part as the scene has it: kit, part, params, faces, shells, each socket's world frame, `connection`, `closure` and `frozen`; a frozen part adds `evaluated: {faces}`, and `dirty` (with `frozen` false) when a modifier of it is shown again. `faces` is the live mesh's count. Changes nothing and evaluates no modifier. |
|
||||
| `brokkr_kitbash.attach` | `object_name` (the child), `socket`, `parent_name`, `parent_socket`, `roll` (degrees, -360 to 360, default 0) | Seats the child's socket on the parent's and parents it there; the two parts are of one kit or of two whose socket types agree. Reports the child. |
|
||||
| `brokkr_kitbash.detach` | `object_name` | Clears the part's connection and the closure it states; it stays where it stands. Refuses a part that has neither. |
|
||||
| `brokkr_kitbash.roll` | `object_name`, `roll` (degrees, -360 to 360) | Turns an attached part to that roll where it hangs. Refuses a part that is not attached. Reports the part and `closures` as `set_params` does. |
|
||||
|
|
@ -829,7 +840,7 @@ vertices overflow.
|
|||
| `brokkr_kitbash.boolean` | `object_name` (any mesh), `cutter`, `operation` (`DIFFERENCE`, `UNION` or `INTERSECT`; default `DIFFERENCE`) | Adds the cutter to the collection of the target's one live Exact Boolean for the operation, above the Bevel. Refuses a cutter that is the target, is not a mesh, or already cuts it, and a scaled target. Reports the part (or `object` for a mesh that is not one), `booleans: [{cutter, operation}]` (difference, union, intersect; each in the order added; `booleansOmitted` counts rows a receipt had no room for) and `evaluated`. |
|
||||
| `brokkr_kitbash.cut` | `object_name` (any mesh), `cutter_name`, `part` (`box`, `cyl`, `slot`, `slab`), `params`, `origin_x/y/z`, `direction_x/y/z`, `up_x/y/z` (default 0, 0, 1), `roll` (degrees, default 0), `axis_x/y/z` (default 0, 0, 0: the surface normal) | Places a `cutters` part where the ray meets the target, parented to it, and adds it to the target's difference Boolean. Refuses a ray that misses or has no direction, a name an object has, an `up` along the cutter's axis, an `axis` into the surface and a scaled target. Reports `object`, the `cutter` with its floor sockets, and `booleans` (with `booleansOmitted`, as `boolean`). |
|
||||
| `brokkr_kitbash.cut_many` | `object_name` (any mesh), `cuts` (a JSON array of 1 to 64 cutters) | `cut` for several cutters in one action: all placed or none, one evaluation of the target afterwards. Reports `object`, `cutters` (names) and `booleans` (with `booleansOmitted`, as `boolean`). |
|
||||
| `brokkr_kitbash.freeze` | `object_name` (any mesh with modifiers) | Makes the evaluated mesh the object's mesh, holds the live mesh in `kit_frozen` and turns every modifier off, keeping the stack, its collections and the cutters. Refuses a frozen object, one with no modifiers, one with a modifier already off and one Blender does not evaluate. Reports the part (or `object`), `frozen`, `faces`, `volume`, `nonManifoldEdges`, `modifiers` and `booleans`. |
|
||||
| `brokkr_kitbash.freeze` | `object_name` (any mesh with modifiers) | Makes the evaluated mesh the object's mesh, holds the live mesh in `kit_frozen` and turns every modifier off, keeping the stack, its collections and the cutters. Refuses a frozen object, one with no modifiers, one with a modifier already off and one Blender does not evaluate. Reports the part (or `object`), `frozen`, `faces` (live), `evaluated: {faces, volume, nonManifoldEdges}`, `modifiers` and `booleans`. |
|
||||
| `brokkr_kitbash.thaw` | `object_name` | Puts the live mesh back, turns every modifier on and removes the frozen mesh; evaluates nothing. Refuses an object that is not frozen or whose held mesh is gone. Reports `object`, `frozen`, `modifiers` and the live mesh's `faces`. |
|
||||
| `brokkr_kitbash.ribs` | `object_name` (the cage), `ribs_name`, `planes` (a JSON array of 1 to 64 `{origin, normal}`, up to 16000 characters), `standoff`, `depth`, `thickness`, `step`, `holes`, `posts`, `post_r`, `bridge`, `clearance`, `longerons` (a JSON array of 0 to 16 `{origin, axis, toward}`, up to 8000 characters), `longeron`, `longeron_w`, `longeron_h`, `longeron_t` | Derives ribs, lightening holes, posts and longerons from the cage as it is cut, as one mesh object under it. Refuses before it writes anything, naming the plane or longeron. Reports `object`, `ribs`, `thickness`, `sections: [{plane, chains, pieces, length, open}]`, `posts`, `holes`, `longerons: [{index, stations}]` (trimmed to a receipt, with `longeronsOmitted`), `faces`, `volume` and `nonManifoldEdges`. |
|
||||
| `brokkr_kitbash.shell` | `object_name`, `sheet` (a JSON object `{rings, closed, mirror, creases, rim, flip}`, up to 32000 characters), `thickness`, `offset`, `levels`, `bevel`, `count_folds` | Makes a faceted, hollow armor shell from a loft of rings with crease runs, or rebuilds a shell's cage in place under its cutters and ribs. Refuses before it writes anything, naming the field and index. Reports `object`, `rebuilt`, `rings`, `points`, `cageFaces`, `creases`, `folded` (with `count_folds`, the number of the evaluated wall's inner faces that fold; else null), `corners`, `subdividedFaces`, `facing`, `thickness`, `offset`, `levels` and `children`. |
|
||||
|
|
|
|||
|
|
@ -625,11 +625,11 @@ try:
|
|||
receipt, frozen = send("brokkr_kitbash.freeze", object_name="Tank")
|
||||
after = np.zeros(len(tank.data.polygons), dtype=np.int32)
|
||||
tank.data.polygons.foreach_get("material_index", after)
|
||||
facts = frozen and {k: frozen[k] for k in ("faces", "volume", "nonManifoldEdges")}
|
||||
facts = frozen and frozen["evaluated"]
|
||||
check("freeze makes the evaluated mesh the tank's mesh: the same faces, volume and non-manifold edges, and the tank still evaluates to them",
|
||||
receipt["status"] == "accepted" and facts == shown == measure(tank.data) == evaluated(tank)[0] and tank.data.name == "Tank frozen"
|
||||
and len(bpy.data.meshes) == meshes + 1, [receipt["message"], facts, shown])
|
||||
check("freeze holds the live mesh in kit_frozen and keeps the stack, off, with its collection and cutter", frozen and frozen["frozen"] is True
|
||||
check("freeze holds the live mesh in kit_frozen and keeps the stack, off, with its collection and cutter", frozen and frozen["frozen"] is True and frozen["faces"] == live_faces
|
||||
and tank["kit_frozen"].name == mesh_name and len(tank["kit_frozen"].polygons) == live_faces and stack(tank) == frozen["modifiers"] == ["Kit Difference", "Kit Bevel"]
|
||||
and not any(m.show_viewport or m.show_render for m in tank.modifiers) and tank.modifiers["Kit Difference"].collection.objects[:] == [box]
|
||||
and frozen["booleans"] == [{"cutter": "Box", "operation": "DIFFERENCE"}] and len(bpy.data.collections) == collections and "Box" in bpy.context.scene.objects,
|
||||
|
|
@ -647,7 +647,8 @@ try:
|
|||
refused("freeze on a frozen part", "brokkr_kitbash.freeze", {"object_name": "Tank"}, THAW)
|
||||
receipt, report = send("brokkr_kitbash.report", object_name="Tank")
|
||||
check("a frozen part still reports its sockets where its params put them, and what is attached to it still holds", report and report["parts"][0]["frozen"] is True
|
||||
and report["parts"][0]["sockets"] == sockets_before and report["parts"][0]["faces"] == frozen["faces"] and holds("Tee", "Tank", "b", "port_a", 180.0)[0]
|
||||
and report["parts"][0]["sockets"] == sockets_before and report["parts"][0]["faces"] == live_faces != shown["faces"] and report["parts"][0]["evaluated"] == {"faces": shown["faces"]}
|
||||
and "dirty" not in report["parts"][0] and holds("Tee", "Tank", "b", "port_a", 180.0)[0]
|
||||
and holds("Nozzle", "Tee", "mount", "c", 37.0)[0], report)
|
||||
receipt, report = send("brokkr_kitbash.attach", object_name="Radiator", socket="base", parent_name="Tank", parent_socket="saddle")
|
||||
check("a new part attaches to a frozen one", receipt["status"] == "accepted" and held(report)
|
||||
|
|
@ -661,15 +662,42 @@ try:
|
|||
bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True)
|
||||
check("the held live mesh survives a purge of orphans", bpy.data.meshes.get(mesh_name) is not None and tank["kit_frozen"] == bpy.data.meshes[mesh_name]
|
||||
and len(tank["kit_frozen"].polygons) == live_faces, sorted(m.name for m in bpy.data.meshes))
|
||||
# kit_* belongs to the kit: the bridge's property setter refuses it, so kit_frozen keeps its one writer
|
||||
for name in ("kit_frozen", "customProperties.kit_frozen", "kit_roll", "kit_anything"):
|
||||
refused(f"setObjectCustomProperty on {name}", "setObjectCustomProperty", {"targetObjectName": "Tank", "propertyName": name, "value": "oops"}, "is brokkr_kitbash's own state (kit_*)")
|
||||
# a modifier shown again by hand on a frozen part: the report says dirty, not frozen, and an export that applies modifiers refuses it
|
||||
tank.modifiers["Kit Bevel"].show_viewport = True
|
||||
dirty = send("brokkr_kitbash.report", object_name="Tank")[1]["parts"][0]
|
||||
check("a frozen part with a modifier shown again reports dirty with the modifier, and not frozen", dirty["frozen"] is False and dirty["dirty"] == ["Kit Bevel"]
|
||||
and dirty["faces"] == live_faces, dirty)
|
||||
for label, fields in (("the scene", {}), ("the part by name", {"selection": ["Tank"]})):
|
||||
refused(f"exportGltf applying modifiers over a dirty frozen part: {label}", "exportGltf", {"filepath": "dirty.glb", "applyModifiers": True, **fields},
|
||||
"Tank: frozen (brokkr_kitbash.freeze) with a modifier shown again")
|
||||
refused("set_params on a dirty frozen part", "brokkr_kitbash.set_params", {"object_name": "Tank", "params": "length=1.0"}, THAW)
|
||||
tank.modifiers["Kit Bevel"].show_viewport = False
|
||||
check("with the modifier hidden again the part reports frozen; the refused exports wrote nothing", "dirty" not in send("brokkr_kitbash.report", object_name="Tank")[1]["parts"][0]
|
||||
and send("brokkr_kitbash.report", object_name="Tank")[1]["parts"][0]["frozen"] is True and not (WORK / "dirty.glb").exists(), sorted(p.name for p in WORK.iterdir()))
|
||||
for name in ("Tee", "Tank"):
|
||||
receipt, thawed = send("brokkr_kitbash.thaw", object_name=name)
|
||||
check("thaw puts the live mesh back, turns every modifier on and removes the frozen mesh", receipt["status"] == "accepted" and tank.data.name == mesh_name and "kit_frozen" not in tank
|
||||
and thawed == {"object": "Tank", "frozen": False, "modifiers": ["Kit Difference", "Kit Bevel"], "faces": live_faces} and stack(tank) == ["Kit Difference", "Kit Bevel"]
|
||||
and all(m.show_viewport and m.show_render for m in tank.modifiers) and "Tank frozen" not in bpy.data.meshes and "kit_frozen" not in tee
|
||||
and len(bpy.data.collections) == collections, [receipt["message"], thawed, sorted(m.name for m in bpy.data.meshes)])
|
||||
and len(bpy.data.collections) == collections and not tank.data.use_fake_user and "kit_kept" not in tank.data and tank.data.users == 1,
|
||||
[receipt["message"], thawed, sorted(m.name for m in bpy.data.meshes), tank.data.users])
|
||||
check("the thawed tank evaluates to what it did before freeze, and reports frozen false", evaluated(tank)[0] == shown
|
||||
and send("brokkr_kitbash.report", object_name="Tank")[1]["parts"][0]["frozen"] is False, [evaluated(tank)[0], shown])
|
||||
lost = place("Lost", "plate", location=[0.0, -24.0, 0.0])
|
||||
lost_mesh = lost.data.name
|
||||
send("brokkr_kitbash.freeze", object_name="Lost")
|
||||
lost["kit_frozen"] = "oops" # by hand: no action writes it. The live mesh has lost its one real user
|
||||
bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True)
|
||||
check("a live mesh whose kit_frozen was overwritten by hand survives a purge of orphans", lost_mesh in bpy.data.meshes and bpy.data.meshes[lost_mesh].use_fake_user,
|
||||
sorted(m.name for m in bpy.data.meshes))
|
||||
refused("thaw on a frozen part whose kit_frozen was overwritten names the kept mesh", "brokkr_kitbash.thaw", {"object_name": "Lost"},
|
||||
f"Live meshes freeze kept that no frozen object holds: {lost_mesh};")
|
||||
lost["kit_frozen"] = bpy.data.meshes[lost_mesh] # the way back, by hand, that the refusal names
|
||||
receipt, _ = send("brokkr_kitbash.thaw", object_name="Lost")
|
||||
check("and with the kept mesh put back in kit_frozen it thaws", receipt["status"] == "accepted" and lost.data.name == lost_mesh and not lost.data.use_fake_user, receipt["message"])
|
||||
send("brokkr_kitbash.freeze", object_name="Lost")
|
||||
bpy.data.meshes.remove(lost["kit_frozen"])
|
||||
refused("thaw on a frozen part whose held mesh was removed", "brokkr_kitbash.thaw", {"object_name": "Lost"}, "the live mesh its kit_frozen held is gone")
|
||||
|
|
@ -695,7 +723,7 @@ try:
|
|||
receipt, frozen = send("brokkr_kitbash.freeze", object_name="Plate")
|
||||
check("freeze on a part with no material slot leaves the frozen mesh with none (Blender's Boolean shows it with one empty slot); a linked duplicate keeps the live mesh",
|
||||
receipt["status"] == "accepted" and shown_slots == [None] and len(plate.data.materials) == 0 and len(plate.material_slots) == 0
|
||||
and frozen["booleans"] == second["booleans"] and {k: frozen[k] for k in ("faces", "volume", "nonManifoldEdges")} == shown
|
||||
and frozen["booleans"] == second["booleans"] and frozen["evaluated"] == shown
|
||||
and twin.data.name == "Plate" and plate["kit_frozen"] == twin.data and all(m.show_viewport for m in twin.modifiers),
|
||||
[shown_slots, len(plate.data.materials), len(plate.material_slots), frozen])
|
||||
bpy.data.objects.remove(twin)
|
||||
|
|
@ -803,12 +831,14 @@ try:
|
|||
send("brokkr_kitbash.thaw", object_name=obj.name)
|
||||
bpy.app.handlers.depsgraph_update_post.remove(seen)
|
||||
medians = {state: sorted(seconds for seconds, _ in rows)[1] for state, rows in costs.items()}
|
||||
R["frozenCost"] = {"liveSeconds": round(medians["live"], 4), "frozenSeconds": round(medians["frozen"], 5),
|
||||
"live": [[round(s, 4), names] for s, names in costs["live"]], "frozen": [[round(s, 5), names] for s, names in costs["frozen"]]}
|
||||
# wall time is this machine's: printed, and kept out of the result file, which carries what was re-evaluated
|
||||
SECONDS = {"live": [round(s, 4) for s, _ in costs["live"]], "frozen": [round(s, 5) for s, _ in costs["frozen"]], "frozenOverLive": medians["frozen"] / medians["live"]}
|
||||
print("SECONDS", SECONDS, flush=True)
|
||||
R["frozenCost"] = {state: [names for _, names in rows] for state, rows in costs.items()}
|
||||
check("removing an orphan mesh re-evaluates the three live cut tanks, and none of them frozen", all(names == ["Cold0", "Cold1", "Cold2"] for _, names in costs["live"])
|
||||
and all(names == [] for _, names in costs["frozen"]), R["frozenCost"])
|
||||
check("and the update with them frozen costs under the bound of what it costs with them live",
|
||||
reading("frozenCost", medians["frozen"] / medians["live"]) < FROZEN_COST, R["frozenCost"])
|
||||
SECONDS["frozenOverLive"] < FROZEN_COST, SECONDS)
|
||||
except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, printed and written, not a missing result file
|
||||
check(f"no uncaught error after: {R['checks'][-1]['name'] if R['checks'] else 'the start'}", False, traceback.format_exc().splitlines()[-6:])
|
||||
|
||||
|
|
|
|||
|
|
@ -576,6 +576,51 @@
|
|||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: setObjectCustomProperty on kit_frozen",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: setObjectCustomProperty on customProperties.kit_frozen",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: setObjectCustomProperty on kit_roll",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: setObjectCustomProperty on kit_anything",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "a frozen part with a modifier shown again reports dirty with the modifier, and not frozen",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: exportGltf applying modifiers over a dirty frozen part: the scene",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: exportGltf applying modifiers over a dirty frozen part: the part by name",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: set_params on a dirty frozen part",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "with the modifier hidden again the part reports frozen; the refused exports wrote nothing",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "thaw puts the live mesh back, turns every modifier on and removes the frozen mesh",
|
||||
"ok": true,
|
||||
|
|
@ -586,6 +631,21 @@
|
|||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "a live mesh whose kit_frozen was overwritten by hand survives a purge of orphans",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: thaw on a frozen part whose kit_frozen was overwritten names the kept mesh",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "and with the kept mesh put back in kit_frozen it thaws",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: thaw on a frozen part whose held mesh was removed",
|
||||
"ok": true,
|
||||
|
|
@ -658,7 +718,6 @@
|
|||
"close nudged": 0.00032,
|
||||
"closed": 3.9e-07,
|
||||
"cut": 0.25,
|
||||
"frozenCost": 0.0016,
|
||||
"kept": 6e-08,
|
||||
"nudged": 0.00032,
|
||||
"roll": 6.6e-06,
|
||||
|
|
@ -699,47 +758,27 @@
|
|||
"nonManifoldEdges": 0
|
||||
},
|
||||
"frozenCost": {
|
||||
"liveSeconds": 1.0356,
|
||||
"frozenSeconds": 0.00168,
|
||||
"live": [
|
||||
[
|
||||
1.0412,
|
||||
[
|
||||
"Cold0",
|
||||
"Cold1",
|
||||
"Cold2"
|
||||
]
|
||||
"Cold0",
|
||||
"Cold1",
|
||||
"Cold2"
|
||||
],
|
||||
[
|
||||
1.0356,
|
||||
[
|
||||
"Cold0",
|
||||
"Cold1",
|
||||
"Cold2"
|
||||
]
|
||||
"Cold0",
|
||||
"Cold1",
|
||||
"Cold2"
|
||||
],
|
||||
[
|
||||
0.9348,
|
||||
[
|
||||
"Cold0",
|
||||
"Cold1",
|
||||
"Cold2"
|
||||
]
|
||||
"Cold0",
|
||||
"Cold1",
|
||||
"Cold2"
|
||||
]
|
||||
],
|
||||
"frozen": [
|
||||
[
|
||||
0.00168,
|
||||
[]
|
||||
],
|
||||
[
|
||||
0.00264,
|
||||
[]
|
||||
],
|
||||
[
|
||||
0.00165,
|
||||
[]
|
||||
]
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
]
|
||||
},
|
||||
"ok": true
|
||||
|
|
|
|||
|
|
@ -445,8 +445,10 @@ except Exception: # noqa: BLE001 whatever it was, it is a failed check with a
|
|||
finally:
|
||||
R["ok"] = all(c["ok"] for c in R["checks"])
|
||||
R["readings"] = {name: float(f"{value:.2g}") for name, value in sorted(R["readings"].items())}
|
||||
costs = R.pop("costs", None) # wall time is this machine's: printed, and kept out of the result file
|
||||
Path(OUT + ".result.json").write_text(json.dumps(R, indent=1, default=str), encoding="utf-8")
|
||||
for c in R["checks"]:
|
||||
print("CHECK", "ok " if c["ok"] else "FAIL", c["name"], "" if c["ok"] else c["detail"], flush=True)
|
||||
print("READINGS", R["readings"], R["costs"], flush=True)
|
||||
print("READINGS", R["readings"], flush=True)
|
||||
print("SECONDS", costs, flush=True)
|
||||
sys.exit(0 if R["ok"] else 1)
|
||||
|
|
|
|||
|
|
@ -183,14 +183,6 @@
|
|||
"soft": 5.8,
|
||||
"solid": 0.027
|
||||
},
|
||||
"costs": {
|
||||
"shell": 0.0059,
|
||||
"shellCountingFolds": 0.0091,
|
||||
"evaluation": 0.0022,
|
||||
"rebuildUnderCuts": 1.7,
|
||||
"rebuildCall": 1.6,
|
||||
"rebuildCallCountingFolds": 1.6
|
||||
},
|
||||
"folds": {
|
||||
"seeded": {
|
||||
"5185 offset -1": [
|
||||
|
|
|
|||
|
|
@ -438,6 +438,14 @@ try:
|
|||
refused("nine clamps", {**FEED, "clamps": json.dumps([{"socket": "SeatA:front"}] * 9)}, "clamps must be a JSON array of 0 to 8 objects")
|
||||
refused("a pin crossed with no joint", {k: v for k, v in FEED.items() if k != "joint"}, "The hose crosses the pin of 'Shin' on 'Thigh' (socket 'end_b_back'): give joint")
|
||||
refused("a joint where no pin is crossed", {**LINE, "object_name": "New", "joint": json.dumps(JOINT)}, "joint is given and the hose crosses no pin")
|
||||
feed.modifiers.new("Smooth", "SUBSURF") # by hand: a hose has no modifiers of its own, and freeze takes any mesh that has one
|
||||
receipt, chilled = send("brokkr_kitbash.freeze", object_name="Feed")
|
||||
check("a hose given a modifier freezes", receipt["status"] == "accepted" and chilled and chilled["frozen"] is True and feed.data.name == "Feed frozen", receipt["message"])
|
||||
refused("a rebuild of a frozen hose", FEED, "'Feed' is frozen, and rebuilding it needs its live mesh and modifiers: thaw it first")
|
||||
send("brokkr_kitbash.thaw", object_name="Feed")
|
||||
feed.modifiers.remove(feed.modifiers["Smooth"])
|
||||
receipt, thawed = send("brokkr_kitbash.hose", **FEED)
|
||||
check("the thawed hose rebuilds", receipt["status"] == "accepted" and "Feed frozen" not in bpy.data.meshes and thawed["nonManifoldEdges"] == 0, receipt["message"])
|
||||
place("Jack", "actuator", "body_r=0.0534;body_len=0.2;extension=0")
|
||||
send("brokkr_kitbash.attach", object_name="Jack", socket="base", parent_name="Shin", parent_socket="end_b", roll=90.0)
|
||||
bpy.context.view_layer.update()
|
||||
|
|
|
|||
|
|
@ -301,6 +301,21 @@
|
|||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "a hose given a modifier freezes",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: a rebuild of a frozen hose",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "the thawed hose rebuilds",
|
||||
"ok": true,
|
||||
"detail": null
|
||||
},
|
||||
{
|
||||
"name": "refused, scene unchanged: two pins crossed",
|
||||
"ok": true,
|
||||
|
|
|
|||
|
|
@ -403,12 +403,12 @@ try:
|
|||
receipt, frozen = send("brokkr_kitbash.freeze", object_name="Plate")
|
||||
check("freeze keeps the three modifiers, off, the three collections they read and every cutter in the scene", receipt["status"] == "accepted"
|
||||
and frozen["booleans"] == report["booleans"] and len(bpy.data.collections) == collections and frozen["modifiers"] == stack(plate) == ["Kit Difference", "Kit Union", "Kit Intersect", "Kit Bevel"]
|
||||
and not any(m.show_viewport or m.show_render for m in plate.modifiers) and {k: frozen[k] for k in ("faces", "volume", "nonManifoldEdges")} == shown == evaluated(plate)[0]
|
||||
and not any(m.show_viewport or m.show_render for m in plate.modifiers) and frozen["evaluated"] == shown == evaluated(plate)[0]
|
||||
and all(name in bpy.context.scene.objects for name in ("Hole", "Boss", "Keep")), [receipt["message"], frozen, shown])
|
||||
cage_stack, cage_mesh = stack(cage), cage.data.name
|
||||
receipt, frozen = send("brokkr_kitbash.freeze", object_name="Cage")
|
||||
check("freeze takes the cage, which is not a kit part: its evaluated wall, its stack off, its cutters still its children", receipt["status"] == "accepted" and frozen["object"] == "Cage"
|
||||
and "kit" not in frozen and frozen["frozen"] is True and {k: frozen[k] for k in ("faces", "volume", "nonManifoldEdges")} == cage_shown == evaluated(cage)[0]
|
||||
and "kit" not in frozen and frozen["frozen"] is True and frozen["evaluated"] == cage_shown == evaluated(cage)[0]
|
||||
and frozen["modifiers"] == stack(cage) == cage_stack and not any(m.show_viewport or m.show_render for m in cage.modifiers) and cage.data.name == "Cage frozen"
|
||||
and bpy.data.objects["Bay"].parent == cage and len(bpy.data.collections) == collections, [receipt["message"], frozen and frozen["modifiers"], cage_shown])
|
||||
refused("ribs from a frozen cage", "brokkr_kitbash.ribs", {"object_name": "Cage", "ribs_name": "ColdRibs", "planes": json.dumps([{"origin": [0.0, 0.0, 0.5], "normal": [0.0, 0.0, 1.0]}])}, THAW)
|
||||
|
|
@ -442,7 +442,7 @@ try:
|
|||
wall = evaluated(bpy.data.objects["Lid"])[0]
|
||||
receipt, frozen = send("brokkr_kitbash.freeze", object_name="Lid")
|
||||
check("freeze takes a shell: the wall its Kit Subsurf and Kit Solidify make", receipt["status"] == "accepted" and frozen["modifiers"] == ["Kit Subsurf", "Kit Solidify"]
|
||||
and {k: frozen[k] for k in ("faces", "volume", "nonManifoldEdges")} == wall and wall["faces"] > 2 * 6 * 16, [receipt["message"], frozen, wall])
|
||||
and frozen["evaluated"] == wall and wall["faces"] > 2 * 6 * 16, [receipt["message"], frozen, wall])
|
||||
refused("a rebuild of a frozen shell", "brokkr_kitbash.shell", lid, THAW)
|
||||
refused("a rebuild of a frozen shell that counts folds", "brokkr_kitbash.shell", {**lid, "count_folds": True}, THAW)
|
||||
send("brokkr_kitbash.thaw", object_name="Lid")
|
||||
|
|
|
|||
|
|
@ -609,6 +609,16 @@ class NodeActionTests(unittest.TestCase):
|
|||
self.assertIn("setModifierInput", receipt["message"])
|
||||
self.assertFalse(hasattr(host, "custom"))
|
||||
|
||||
def test_custom_property_in_the_kit_namespace_is_refused(self):
|
||||
self.group()
|
||||
host = self.bpy.data.objects["Host"]
|
||||
for name in ("kit_frozen", "customProperties.kit_frozen", "kit_roll", "kit_"):
|
||||
receipt = self.refused(action="setObjectCustomProperty", targetObjectName="Host", propertyName=name, value=3)
|
||||
self.assertIn("brokkr_kitbash's own state (kit_*)", receipt["message"])
|
||||
self.assertFalse(hasattr(host, "custom"))
|
||||
self.accepted(action="setObjectCustomProperty", targetObjectName="Host", propertyName="kitchen", value=3)
|
||||
self.assertEqual(host.custom, ("kitchen", 3))
|
||||
|
||||
def test_custom_property_sharing_only_a_display_name_is_an_ordinary_property(self):
|
||||
self.group()
|
||||
host = self.bpy.data.objects["Host"]
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ class FakeBpy:
|
|||
for o in self.data.objects.values():
|
||||
o.selected = o is self.mesh
|
||||
o.select_get = (lambda o=o: o.selected)
|
||||
o.modifiers, o.get = [], (lambda key, default=None: default) # no modifier, no custom property
|
||||
o.select_set = (lambda state, o=o: setattr(o, "selected", state))
|
||||
add = lambda kind: (lambda mode, undo, **kw: self.add_object(kind, kw, (mode, undo)))
|
||||
self.ops = NS(import_scene=NS(gltf=self.import_gltf), render=NS(render=self.render_still),
|
||||
|
|
@ -291,6 +292,21 @@ class ActionTests(unittest.TestCase):
|
|||
self.assertEqual(call["selected_at_call"], ["Cam", "Lamp"])
|
||||
self.assertEqual([o.name for o in self.bpy.data.objects.values() if o.selected], ["Cube"])
|
||||
|
||||
def test_export_applying_modifiers_refuses_a_frozen_object_with_a_modifier_shown(self):
|
||||
mesh = self.bpy.data.objects["Cube"]
|
||||
mesh.get = lambda key, default=None: "live mesh" if key == "kit_frozen" else default
|
||||
mesh.modifiers = [NS(show_viewport=False), NS(show_viewport=True)]
|
||||
for fields in ({}, {"selection": ["Cube"]}):
|
||||
receipt = self.run_action(action="exportGltf", filepath="dirty.glb", **fields)
|
||||
self.assertEqual(receipt["status"], "failed", receipt)
|
||||
self.assertIn("Cube: frozen (brokkr_kitbash.freeze) with a modifier shown again", receipt["message"])
|
||||
self.assertEqual((self.bpy.exported, list((self.root / "out").iterdir())), ([], []))
|
||||
for fields in ({"applyModifiers": False}, {"selection": ["Cam"]}): # nothing applied, or the object not exported
|
||||
receipt = self.run_action(action="exportGltf", filepath=f"ok{len(self.bpy.exported)}.glb", **fields)
|
||||
self.assertEqual(receipt["status"], "accepted", receipt)
|
||||
mesh.modifiers[1].show_viewport = False
|
||||
self.assertEqual(self.run_action(action="exportGltf", filepath="frozen.glb")["status"], "accepted")
|
||||
|
||||
def test_export_without_a_selection_never_touches_selection(self):
|
||||
def explode(*a, **k):
|
||||
raise AssertionError("selection touched")
|
||||
|
|
|
|||
Loading…
Reference in a new issue