Skip to content
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

Add "Parent Relative" option to location nodes #2242

Merged
merged 7 commits into from Jun 29, 2021
Merged

Add "Parent Relative" option to location nodes #2242

merged 7 commits into from Jun 29, 2021

Conversation

knowledgenude
Copy link
Collaborator

@knowledgenude knowledgenude commented Jun 27, 2021

Proposal fix for #2241

  • Improved docs for World Vector to Local Space and Vector to Object Orientation nodes to be used in cases where don't have parent.
  • Added Subtract option for World Vector to Local Space node

@@ -10,5 +17,6 @@ class GetLocationNode(ArmLogicTreeNode):
def init(self, context):
super(GetLocationNode, self).init(context)
self.add_input('ArmNodeSocketObject', 'Object')
self.add_input('NodeSocketBool', 'Parent Relative')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, nice work! I think you might need to add a node replacement routine so that this input is automatically added to older nodes. The same holds for the other changed nodes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, i didn't know about that! Any example of how to do so?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably just use this:

def get_replacement_node(self, node_tree: bpy.types.NodeTree):
    if self.arm_version not in (0, 1):
        raise LookupError()
    return NodeReplacement.Identity(self)

This will update the node but keep all socket connections the same as there is only a new socket but nothing else has changed. Don't forget to also increment the arm_version attribute of the node.

You can try the changes by creating a file without the changes in this PR, then apply the changes again and then you can execute the "Replace Nodes" operator in the F3 search menu to test if the replacement works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks. Also fixed many typos i left and removed the subtract option i've added. Now the World Vec To Local node works as it should by default to avoid confusion. I didn't incremented its arm version because it is more a bug fix, but if you think i should increment then no problem :)

Also i've concluded that i could remove the input length verification from the nodes. Any case you can tell me what is better to do!

@knowledgenude knowledgenude changed the title Add "Relative Parent" option to location nodes Add "Parent Relative" option to location nodes Jun 28, 2021
@luboslenco luboslenco merged commit e308d90 into armory3d:master Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants