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 "set_bone_position" API method #124

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ProtonGustave
Copy link

Add "set_bone_position" method to directly change bones positions. Will be useful for procedural animations and constraint targets.

@britzl britzl requested review from JCash and AGulev February 12, 2023 11:51
Copy link
Contributor

@JCash JCash left a comment

Choose a reason for hiding this comment

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

PR Looks good.
Some changes needed.

Q: What is the benefit of this function over functions like set_ik_target_position and set_ik_target ?

@@ -1396,6 +1396,24 @@ namespace dmSpine
*instance_id = dmGameObject::GetIdentifier(bone_instance);
return true;
}

bool CompSpineModelSetBonePosition(SpineModelComponent* component, dmhash_t bone_name, Point3 position)
Copy link
Contributor

Choose a reason for hiding this comment

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

Our code code convention here is const dmVMath::Point3& position)

@@ -97,6 +97,8 @@ namespace dmSpine

bool CompSpineModelGetBone(SpineModelComponent* component, dmhash_t bone_name, dmhash_t* instance_id);

bool CompSpineModelSetBonePosition(SpineModelComponent* component, dmhash_t bone_name, Vectormath::Aos::Point3 position);
Copy link
Contributor

@JCash JCash Feb 12, 2023

Choose a reason for hiding this comment

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

The correct type is const dmVMath::Point3&

@@ -679,6 +679,47 @@ namespace dmSpine
return 0;
}

/*# Set world space bone position
* Note that bones positions will be overwritten by active animations and constraints(IK, Path, Transform...), only change positions of bones that is not affected by those.
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct tag for notes is @note

@@ -780,6 +821,7 @@ namespace dmSpine
{"set_ik_target_position", SpineComp_SetIKTargetPosition},
{"set_ik_target", SpineComp_SetIKTarget},
{"reset_ik_target", SpineComp_ResetIK},
{"set_bone_position", SpineComp_SetBonePosition},
Copy link
Contributor

Choose a reason for hiding this comment

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

In our api, we use "world" in the names (See go.get_world_position())
This function should be called set_world_bone_position().

That, or make it accept local space coordinate.

Comment on lines +711 to +712
dmhash_t bone_id = dmScript::CheckHashOrString(L, 2);
Vectormath::Aos::Vector3* position = dmScript::CheckVector3(L, 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

We only do casts if we know it's the correct type.
Here, they're not the same: Vector3 != Point3

You can create a Point3 like so: Point3(v3)

@britzl
Copy link
Contributor

britzl commented Aug 18, 2023

@ProtonGustave any chance you will look into the PR feedback? Or should we close this PR due to inactivity?

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.

3 participants