Use multiple light positions for CAO lighting
[oweals/minetest.git] / src / client / content_cao.h
index ca1518fb22ccc99fddbb9ad74fb774922281c65f..699148c52306416eaaa4ea318db4e04678afb888 100644 (file)
@@ -102,10 +102,14 @@ private:
        bool m_animation_loop = true;
        // stores position and rotation for each bone name
        std::unordered_map<std::string, core::vector2d<v3f>> m_bone_position;
+
+       int m_attachment_parent_id = 0;
+       std::unordered_set<int> m_attachment_child_ids;
        std::string m_attachment_bone = "";
        v3f m_attachment_position;
        v3f m_attachment_rotation;
        bool m_attached_to_local = false;
+
        int m_anim_frame = 0;
        int m_anim_num_frames = 1;
        float m_anim_framelength = 0.2f;
@@ -121,8 +125,12 @@ private:
        u8 m_last_light = 255;
        bool m_is_visible = false;
        s8 m_glow = 0;
+       // Material
+       video::E_MATERIAL_TYPE m_material_type;
+       // Settings
+       bool m_enable_shaders = false;
 
-       std::vector<u16> m_children;
+       bool visualExpiryRequired(const ObjectProperties &newprops) const;
 
 public:
        GenericCAO(Client *client, ClientEnvironment *env);
@@ -152,18 +160,20 @@ public:
 
        virtual bool getSelectionBox(aabb3f *toset) const;
 
-       v3f getPosition();
+       const v3f getPosition() const;
 
-       inline const v3f &getRotation()
+       void setPosition(const v3f &pos)
        {
-               return m_rotation;
+               pos_translator.val_current = pos;
        }
 
+       inline const v3f &getRotation() const { return m_rotation; }
+
        const bool isImmortal();
 
-       scene::ISceneNode *getSceneNode();
+       scene::ISceneNode *getSceneNode() const;
 
-       scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode();
+       scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode() const;
 
        // m_matrixnode controls the position and rotation of the child node
        // for all scene nodes, as a workaround for an Irrlicht problem with
@@ -178,6 +188,12 @@ public:
                return m_matrixnode->getRelativeTransformationMatrix();
        }
 
+       inline const core::matrix4 &getAbsolutePosRotMatrix() const
+       {
+               assert(m_matrixnode);
+               return m_matrixnode->getAbsoluteTransformation();
+       }
+
        inline f32 getStepHeight() const
        {
                return m_prop.stepheight;
@@ -199,10 +215,17 @@ public:
        }
 
        void setChildrenVisible(bool toset);
-
+       void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
+       void getAttachment(int *parent_id, std::string *bone, v3f *position,
+                       v3f *rotation) const;
+       void clearChildAttachments();
+       void clearParentAttachment();
+       void addAttachmentChild(int child_id);
+       void removeAttachmentChild(int child_id);
        ClientActiveObject *getParent() const;
-
-       void setAttachments();
+       const std::unordered_set<int> &getAttachmentChildIds() const
+       { return m_attachment_child_ids; }
+       void updateAttachments();
 
        void removeFromScene(bool permanent);
 
@@ -213,11 +236,16 @@ public:
                m_visuals_expired = true;
        }
 
-       void updateLight(u8 light_at_pos);
+       void updateLight(u32 day_night_ratio);
 
-       void updateLightNoCheck(u8 light_at_pos);
+       void setNodeLight(u8 light);
 
-       v3s16 getLightPosition();
+       /* Get light position(s).
+        * returns number of positions written into pos[], which must have space
+        * for at least 3 vectors. */
+       u16 getLightPosition(v3s16 *pos);
+
+       void updateNametag();
 
        void updateNodePos();
 
@@ -235,8 +263,6 @@ public:
 
        void updateBonePosition();
 
-       void updateAttachments();
-
        void processMessage(const std::string &data);
 
        bool directReportPunch(v3f dir, const ItemStack *punchitem=NULL,