Closed chenpaner closed 10 months ago
The reason Light Painter doesn't have this is it's one of those weird Blender "quirks" ie design choices. In short, when a tool calls a modal operator via shortcut (in this case, a mouse click), it directly uses the keymap's parameter defaults, not the values from the previous run. That's why the tools don't remember previous settings, even though operators in other contexts do.
A couple fixes:
This is the code for the first fix (I'm just documenting this for myself and posterity), found on Stack Exchange:
wm = context.window_manager
keyconfigs = wm.keyconfigs
kmi = keyconfigs.find_item_from_operator(self.bl_idname)[1]
for attr in self.properties.keys():
setattr(kmi.properties, attr, getattr(self, attr))
Thank you very much for your response. I'm sorry that I don't understand programming languages; I've just started learning a bit of Python. The suggestion to modify the lamp_type property came from seeing a similar property in another plugin that can retain the previous selection instead of resetting to the default option every time. Here is the link to that plugin; you can take a look. I'm not sure if it will be helpful to you, but your plugin is already fantastic!
Thank you for sharing the link! And I appreciate your words on Light Painter, it really means a lot :)
The nice thing with Blender is "retain the previous options" is a given feature for operators. I don't even have to code it, and neither did the add-on you linked. But for some reason, Blender doesn't reuse the last parameters when run by tools (ie those left-hand buttons in the 3D view, including Light Painter). It just uses to the default values in the keymap, no matter what. I'm trying to figure out why Blender coded it that way. Because there may be a bigger (but better) solution that naturally fits with Blender than just doing a hacky workaround.
Other tools' settings are in the separate tools header and panel, not the redo panel. So it may be that Blender devs would rather I put all the tool properties up there and expose the properties like you said.
I'm not asking you to have the answers. I'm just sharing my thoughts for you and others to see. I'll take some time to think about it (I'm on US holiday anyway), but any feedback from you and others is appreciated.
Quick update here: after giving it more thought, I have some ideas planned for the next version upgrade to help resolve this, including adding the light type in the toolshelf header. But it'll take advantage of keyboard shortcuts and have a (real) live updates.
So I'll mark this issue as "In progress" :)
I added the lamp type for the Light Paint tool shelf. I added some for other tools as well. The redo panel is still available and working.
If there's any other parameters that you feel are worth exposing, you can open a new issue. Closing this one.
Hi, there is a small suggestion, you can consider it, every time I add a light is the default point light, although I can modify lamp_type default = 'AREA', but it seems not convenient enough, maybe lamp_type: bpy.props. EnumProperty can be changed to a scene property, so that when adding the second light is still the default light type after the first modification