From dff2e64d00c01246cd52505641b3206ee278310a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Wed, 30 Apr 2025 17:09:32 -0300 Subject: [PATCH] GetBoneIndex/GetBoneCount --- src/playsim/p_actionfunctions.cpp | 32 +++++++++++++++++++++++++++ wadsrc/static/zscript/actors/actor.zs | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/src/playsim/p_actionfunctions.cpp b/src/playsim/p_actionfunctions.cpp index b21ffb7c44..98897d8731 100644 --- a/src/playsim/p_actionfunctions.cpp +++ b/src/playsim/p_actionfunctions.cpp @@ -5558,6 +5558,17 @@ static int GetBoneNameNative(AActor * self, int bone_index) return mdl->GetJointName(bone_index).GetIndex(); } +static int GetBoneIndexNative(AActor * self, int boneName_i) +{ + FName bone_name {ENamedName(boneName_i)}; + + int bone_index; + + FModel * mdl = GetBoneShared(self, 0, bone_index, &bone_name); + + return bone_index; +} + DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetBoneName, GetBoneNameNative) { PARAM_SELF_PROLOGUE(AActor); @@ -5566,6 +5577,14 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetBoneName, GetBoneNameNative) ACTION_RETURN_INT(GetBoneNameNative(self, boneindex)); } +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetBoneIndex, GetBoneIndexNative) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_NAME(bonename); + + ACTION_RETURN_INT(GetBoneIndexNative(self, bonename.GetIndex())); +} + static int GetBoneParentNative(AActor * self, int bone_index) { FModel * mdl = GetBoneShared(self, 0, bone_index, nullptr); @@ -5702,6 +5721,19 @@ DEFINE_ACTION_FUNCTION(AActor, GetNamedBoneDir) ACTION_RETURN_VEC3(DVector3(mdl->GetJointDir(bone_index))); } +static int GetBoneCountNative(AActor * self) +{ + FModel * mdl = SetGetBoneShared(self, 0); + + return mdl->NumJoints(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetBoneCount, GetBoneCountNative) +{ + PARAM_SELF_PROLOGUE(AActor); + + ACTION_RETURN_INT(GetBoneCountNative(self)); +} diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 8d23ea6881..f37c5e3bab 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1395,6 +1395,7 @@ class Actor : Thinker native native version("4.15.1") void GetRootBones(out Array rootBones); native version("4.15.1") Name GetBoneName(int boneIndex); + native version("4.15.1") int GetBoneIndex(Name boneName); native version("4.15.1") int GetBoneParent(int boneIndex); native version("4.15.1") int GetNamedBoneParent(Name boneName); // return value lower than 0 means it's a root bone, and as such has no parent @@ -1409,6 +1410,9 @@ class Actor : Thinker native // this is the direction of the bone in the armature, does not take the current animation or offset into account at all native version("4.15.1") Vector3 GetBoneDir(int boneIndex); native version("4.15.1") Vector3 GetNamedBoneDir(Name boneName); + + native version("4.15.1") int GetBoneCount(); + //================================================ //