#Can this be implemented as an inspector plugin for my modifier addon?

1 messages · Page 1 of 1 (latest)

leaden swift
#

Hi there. I'm in the process of creating my first addon, a modifier system that's non-destructive, type-agnostic and hopefully easy to use. it's similar to the strategy design pattern. I'm taking inspiration from an older addon made by samdze for 3.x, but my approach is different, notably because it involves more classes, and the result is that I don't really know how to implement inspector integration for it.
https://gitlab.com/Feymood/alchemy-modifiers this is my current code. sorry about the funky class naming, but writing docstrings like "the modifierhandler modifier modifies the real property of the target property of the target node" got to me after a while, so i went a little skeuomorphic with it, while trying to remain consistent in documentation

brief explanation: the system revolves around an alembic node, which targets one node. this alembic then holds any number of flasks which each target one property on the target node. each flask holds the initial value of their target property and any number of modifiers for it, and takes care of sorting them if needed. then, you can call the alembic to update/'mix' the flasks, at which point each flask takes its property's initial value, applies the modifiers to it, and assigns the final value to the real target property.

the alembic holds a dictionary with strings as keys corresponding to property names, and flasks as values. flasks are their own class deriving from object (i originally had them as just dictionaries but then i realized i needed them to signal to the alembic) holding an array of modifiers. modifiers are also their own class, deriving from resource, with the goal being to allow users to extend it to implement modifiers for any variant type, including their own custom classes. there's also a number of usable modifier classes that will be included in the addon; specifically ones for basic arithmetic.

#

while i'm fairly confident this is the most logical architecture at this point, i want all this to be easily editable from the inspector and i don't really know how. all i know about inspector plugins as of now is from following the tutorial in the docs and it didn't really help me figure out what i needed to do for my case.
the first thing i noticed is that you can't set a dictionary var as an export if one of its types is an Object, like my alembic's Dictionary[String,Flask]:

Error at (58, 1): Export type can only be built-in, a resource, a node, or an enum.

makes sense, because the editor wouldn't know what to make of a custom type with no defined inspector widget; but how would I go about adding one for my custom class, then? for the sake of demonstration, I switched flask's parent to resource, but in practice, this doesn't make sense as flask is mostly a container class and doesn't benefit from serialization, so I'd rather avoid it.

the goal would be that when you look at an alembic, you'd have a button to add a flask, which would then show a popup for you to select a property on the target node. then the flask would have its own widget where you can toggle its properties like active, preview, sorted, as well as add to its array of modifiers using the same inspector widget as a normal array. additionally, select modifier types that are agnostic to the property's value, like substitutemodifier here which just substitutes the value of the property with its own parameter, should automatically change their parameters' widgets to match the property's type; i.e. if your flask is targeting a Vector2D and you add a substitutemodifier, the substitutemodifier's value field should change to a vector2D.

sorry, this is a bit of a lot, but I hope it clarifies what i'm going for. any advice on how i could achieve this using the engine's features? is it achievable?

leaden swift
#

bumping, assuming that's ok!