8 #ifndef hifi_NestableTransformNode_h
9 #define hifi_NestableTransformNode_h
11 #include "TransformNode.h"
13 #include "SpatiallyNestable.h"
15 #include "RegisteredMetaTypes.h"
18 class BaseNestableTransformNode :
public TransformNode {
20 BaseNestableTransformNode(std::weak_ptr<T> spatiallyNestable,
int jointIndex) :
21 _spatiallyNestable(spatiallyNestable),
22 _jointIndex(jointIndex) {
23 auto nestablePointer = _spatiallyNestable.lock();
24 if (nestablePointer) {
25 if (nestablePointer->getNestableType() != NestableType::Avatar) {
26 glm::vec3 nestableDimensions = getActualScale(nestablePointer);
27 _baseScale = glm::max(glm::vec3(0.001f), nestableDimensions);
32 Transform getTransform()
override {
33 std::shared_ptr<T> nestable = _spatiallyNestable.lock();
39 Transform jointWorldTransform = nestable->getJointTransform(_jointIndex, success);
45 jointWorldTransform.setScale(getActualScale(nestable) / _baseScale);
47 return jointWorldTransform;
50 QVariantMap toVariantMap()
const override {
53 auto nestable = _spatiallyNestable.lock();
55 map[
"parentID"] = nestable->getID();
56 map[
"parentJointIndex"] = _jointIndex;
57 map[
"baseParentScale"] = vec3toVariant(_baseScale);
63 glm::vec3 getActualScale(
const std::shared_ptr<T>& nestablePointer)
const;
66 std::weak_ptr<T> _spatiallyNestable;
68 glm::vec3 _baseScale { 1.0f };
71 class NestableTransformNode :
public BaseNestableTransformNode<SpatiallyNestable> {
73 NestableTransformNode(std::weak_ptr<SpatiallyNestable> spatiallyNestable,
int jointIndex) : BaseNestableTransformNode(spatiallyNestable, jointIndex) {};