mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-14 01:19:59 +00:00
Changed to global for testing. Since it a getter - probably should change to regular object.
This commit is contained in:
parent
5750be2ad1
commit
c0f733cdce
@ -223,26 +223,27 @@ namespace MWLua
|
||||
{ "CarriedRight", MWWorld::InventoryStore::Slot_CarriedRight },
|
||||
{ "CarriedLeft", MWWorld::InventoryStore::Slot_CarriedLeft },
|
||||
{ "Ammunition", MWWorld::InventoryStore::Slot_Ammunition } }));
|
||||
actor["getBonePosition"] = [](const SelfObject& self, std::string_view boneName) -> sol::optional<osg::Vec3d> {
|
||||
const MWWorld::Class& cls = self.ptr().getClass();
|
||||
if (!cls.isActor())
|
||||
throw std::runtime_error("Actor expected");
|
||||
actor["getBonePosition"] = [](const GObject& o, std::string_view boneName) -> sol::optional<osg::Vec3f> {
|
||||
const MWWorld::Class& cls = o.ptr().getClass();
|
||||
// Need to accept self OR a global object
|
||||
/*if (!cls.isActor())
|
||||
throw std::runtime_error("Actor expected");*/
|
||||
|
||||
std::optional<osg::Matrix> boneTransform
|
||||
= findBoneWorldTransform(self.ptr().getRefData().getBaseNode(), boneName);
|
||||
= findBoneWorldTransform(o.ptr().getRefData().getBaseNode(), boneName);
|
||||
|
||||
if (!boneTransform.has_value())
|
||||
return sol::nullopt;
|
||||
|
||||
return boneTransform.value().getTrans();
|
||||
return static_cast<osg::Vec3f>(boneTransform.value().getTrans());
|
||||
};
|
||||
actor["getBoneRotation"] = [](const SelfObject& self, std::string_view boneName) -> sol::optional<osg::Quat> {
|
||||
const MWWorld::Class& cls = self.ptr().getClass();
|
||||
actor["getBoneRotation"] = [](const GObject& o, std::string_view boneName) -> sol::optional<osg::Quat> {
|
||||
const MWWorld::Class& cls = o.ptr().getClass();
|
||||
if (!cls.isActor())
|
||||
throw std::runtime_error("Actor expected");
|
||||
|
||||
std::optional<osg::Matrix> boneTransform
|
||||
= findBoneWorldTransform(self.ptr().getRefData().getBaseNode(), boneName);
|
||||
= findBoneWorldTransform(o.ptr().getRefData().getBaseNode(), boneName);
|
||||
|
||||
if (!boneTransform.has_value())
|
||||
return sol::nullopt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user