-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create "constructor" constraints. #272
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
5b618b3
to
3f04da9
Compare
Note: init_props already computes the constraints value and setting from it's entities. Would be great to reuse/split-out that code. |
ec774b2
to
303d737
Compare
Just found out about this:
|
Well I found out that you cannot make Property values "readonly" for the user on their own, but that you have to declare it in any menu they appear in... or?? Anyway, the functionality is there, I am not super happy with the code structure I went with, I'll have to revise it perhaps.. |
Gave it a quick test and it's just awesome when you make a constraint depend on the value of a reference dimension and interactivley drag stuff around! |
Yep, didn't think about the driver situation :) I'll add it back, but I will have to find an other UI trick to make it interact as a "readonly" property |
For future reference: an old StEx post describes that properties that only have a https://blender.stackexchange.com/a/13702 So either I
|
d8ce5c6
to
07cf810
Compare
Shouldn't the layout.enabled flag be the solution here? Maybe the StEx post is just too old so it wasn't suggested there. |
The problem is that is disable the whole UILayout in question, column, row... not individual props inside that element. If the readonly attribute is defined in the Property, it is way more portable and better separation of concerns. |
A prop could still be wrapped in it's own sub row..
True, also it seems to break the drivers workflow... I would say a conditional in the setter is the best, least hacky approach. |
I reused the row segments that were available in the menu
That cannot be used because We are also updating the value with the entity size. However, because it gets automatically updated, it is not the end of the world if the user is able to input a value because it will get updated if it isn't solver-compatible. |
And I just received the steam deck, so productivity fell through the floor 😂 |
- Also kinda changes role of init_props -> assign_init_props - Store values as the same logic value, i.e. always stores the radius or the direct angle etc...
decefe1
to
bb294b1
Compare
I am looking forward to read your suggestions for improving the code structure :) |
e640253
to
7a84031
Compare
I'm just sad that you cannot create a driver if the UI element is disabled, but it makes sense not to write to that value through the driver. I guess that is potential bug when not having a conditional limiter in the setter function. |
We could actually set the property value without triggering the getter/setter/update callbacks, at least from within the constraints classes.
IMO it makes sense that it's not possible to add drivers, what's missing is the "copy as new driver" and "driver datapath" options i suppose... |
I didn't want extra functions to update the private var, but I suppose I can add the extra argument |
Also please let me know about cosmetic changes, I re-read that you were thinking of having the value in brackets, maybe we want to dim the color of the font etc... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few notes so far:
- It seems like the color changes are breaking the constraint highlight when an operator button is hovered (when its tooltip appears) in the interface. Maybe have a look at the HighlightElement mixin class.
- Did you try adding a driver so one constraint has the value of a reference constraint? It's quite a bummer that you cannot use "copy as new driver", do you now if there's another simple way for users to add such a driver?
- Maybe @exegetor could also have a quick look at the checnges regarding the init_props / assign_init_props methods...?
How so? To me the highlight colors display correctly. What UI item are you hovering when it should highlight? I tried to compare with main without any different behaviour w/regards to highlighting colors.
Had to look up how to do that with MakerTales video 👀 but yes! it works only if
I'll make the change with the |
Example test file for the feature :) |
2 things about re-enabling the UI elements:
On a different note, pasting a driver onto a reference constraint doesn't change the size of the reference measurement. After 2 sec of reflection, that is logical, but will probably confuse users. |
9966fd8
to
5fa9b99
Compare
Side note: I created a StEx question for the extra spicy solution: deleting/recreating the setter function https://blender.stackexchange.com/questions/274411/override-edit-the-get-set-functions-of-a-property |
Oops, you are right! The highlight color was just too subtle, sorry about that.
IMO we have to go this route, it's too annoying if you cannot create the driver when a constraint is already set to reference. There needs to be some kind of distinction between reference and normal constraints in the sidebar indeed, not sure how exactly tho, maybe just a separate block with a title "Reference:" ? |
Yeah thats a unfortunate limitation, blender doesn't allow to add drivers from popup menus, that's why we need to display the properties in the sidebar....
Yeah ideally the disabled layout would allow to copy as new driver but disallow adding a driver... but i think we found a ok workaround for the moment. |
@@ -122,7 +122,7 @@ def _get_msg_entities(): | |||
# Store a index-constraint mapping | |||
from collections.abc import Iterable | |||
|
|||
indices = c.create_slvs_data(self.solvesys, group=group) | |||
indices = c.py_data(self.solvesys, group=group) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's quite the fundamental change here, is it really needed for this PR? I would rather have this in a separate PR and apply it also to entities.
But i'm not actually sure this makes sense, The slvs solve system cannot be created and updated at a later point. So a new one is created everytime the solver runs. If we don't explicitly recreate slvs data py_data might return handles from the last solver run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to think of a different way to do it so it doesn't have that many changes to the higher level abstractions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hlorus
Either:
- I rename the
create_slvs_data()
in all the constraints and entities that use it. - I write the "empty return" return step in all the
create_slvs_data()
for the dimensional constraints.
The reason I refactored create_slvs_data()
to py_data()
in the higher level abstraction is because the .py_data
attribute is used by the entities to pass on the solver handles.
I can create a separate PR now that refactors all the entities and constraints to
- have a
py_data()
function that serves as interface and returns the slvs handles.That function should only be implemented by the abstract/mother classes like
GenericX
- have a private function
create_slvs_data()
that generates the data.This function is implemented by all the daughter classes to create handles specific to themselves
I would also suggest a name change for those functions, for example solver_handles()
and generate_solver_handles()
Regarding cosmetics, adding brackets and dimming the text sounds reasonable but i don't have a strong opinion here. |
5fa9b99
to
df67047
Compare
Then I will re-disable the value selection in the popup menu
I haven't tested this, but I believe that a custom Property that only has a
I think we should run a poll in the discord to gauge what people think |
df67047
to
5bd293d
Compare
The functionality of init_props is changed here, if i get it right calling assign_init_props would now have the same effects as init_props had before. Yet there are places (operators/base_constraint.py line 69) where init_props is still called. While i haven't tested it i'm afraid this breaks stuff, was it intentional? |
It was intentional, but I feel like I need to open a discussion topic so we don't pollute the PR too much. |
Okay then i'd say we can merge this, i haven't found anything braking. Maybe just keep an eye open for reports. |
@amrsoll Looks like this PR broke the Angle constraint ;) |
More specifically, this commit: ee09f49 |
Fixes #258
TODO
is_reference
is True.class DimensionalConstraint
inbase_constraint.py