Browse Source

chan: add various property interfaces to animation system

rdb 7 years ago
parent
commit
594e6b394b

+ 3 - 0
panda/src/chan/animBundle.h

@@ -38,6 +38,9 @@ PUBLISHED:
   INLINE double get_base_frame_rate() const;
   INLINE int get_num_frames() const;
 
+  MAKE_PROPERTY(base_frame_rate, get_base_frame_rate);
+  MAKE_PROPERTY(num_frames, get_num_frames);
+
   virtual void output(std::ostream &out) const;
 
 protected:

+ 2 - 0
panda/src/chan/animBundleNode.h

@@ -41,6 +41,8 @@ public:
 PUBLISHED:
   INLINE AnimBundle *get_bundle() const;
 
+  MAKE_PROPERTY(bundle, get_bundle);
+
   static AnimBundle *find_anim_bundle(PandaNode *root);
 
 private:

+ 2 - 0
panda/src/chan/animChannelMatrixDynamic.h

@@ -57,6 +57,8 @@ PUBLISHED:
   INLINE const TransformState *get_value_transform() const;
   INLINE PandaNode *get_value_node() const;
 
+  MAKE_PROPERTY(value_node, get_value_node, set_value_node);
+
 protected:
   virtual AnimGroup *make_copy(AnimGroup *parent) const;
 

+ 2 - 0
panda/src/chan/animChannelMatrixXfmTable.h

@@ -59,6 +59,8 @@ PUBLISHED:
   INLINE bool has_table(char table_id) const;
   INLINE void clear_table(char table_id);
 
+  MAKE_MAP_PROPERTY(tables, has_table, get_table, set_table, clear_table);
+
 public:
   virtual void write(std::ostream &out, int indent_level) const;
 

+ 22 - 0
panda/src/chan/animChannelScalarDynamic.I

@@ -10,3 +10,25 @@
  * @author drose
  * @date 2003-10-20
  */
+
+/**
+ * Gets the value of the channel.  This will return the value explicitly
+ * specified by set_value() unless a value node was specified using
+ * set_value_node().
+ */
+INLINE PN_stdfloat AnimChannelScalarDynamic::
+get_value() const {
+  if (_value_node != nullptr) {
+    return _value->get_pos()[0];
+  } else {
+    return _float_value;
+  }
+}
+
+/**
+ * Returns the node that was set via set_value_node(), if any.
+ */
+INLINE PandaNode *AnimChannelScalarDynamic::
+get_value_node() const {
+  return _value_node;
+}

+ 5 - 8
panda/src/chan/animChannelScalarDynamic.cxx

@@ -84,16 +84,12 @@ has_changed(int, double, int, double) {
  */
 void AnimChannelScalarDynamic::
 get_value(int, PN_stdfloat &value) {
-  if (_value_node != nullptr) {
-    value = _value->get_pos()[0];
-
-  } else {
-    value = _float_value;
-  }
+  value = get_value();
 }
 
 /**
- * Explicitly sets the value.
+ * Explicitly sets the value.  This will remove any node assigned via
+ * set_value_node().
  */
 void AnimChannelScalarDynamic::
 set_value(PN_stdfloat value) {
@@ -104,7 +100,8 @@ set_value(PN_stdfloat value) {
 
 /**
  * Specifies a node whose transform will be queried each frame to implicitly
- * specify the transform of this joint.
+ * specify the transform of this joint.  This will override the values set by
+ * set_value().
  */
 void AnimChannelScalarDynamic::
 set_value_node(PandaNode *value_node) {

+ 5 - 0
panda/src/chan/animChannelScalarDynamic.h

@@ -41,11 +41,16 @@ public:
   virtual bool has_changed(int last_frame, double last_frac,
                            int this_frame, double this_frac);
   virtual void get_value(int frame, PN_stdfloat &value);
+  INLINE PN_stdfloat get_value() const;
+  INLINE PandaNode *get_value_node() const;
 
 PUBLISHED:
   void set_value(PN_stdfloat value);
   void set_value_node(PandaNode *node);
 
+  MAKE_PROPERTY(value, get_value, set_value);
+  MAKE_PROPERTY(value_node, get_value_node, set_value_node);
+
 protected:
   virtual AnimGroup *make_copy(AnimGroup *parent) const;
 

+ 2 - 0
panda/src/chan/animChannelScalarTable.h

@@ -44,6 +44,8 @@ PUBLISHED:
   INLINE bool has_table() const;
   INLINE void clear_table();
 
+  MAKE_PROPERTY2(table, has_table, get_table, set_table, clear_table);
+
 public:
   virtual void write(std::ostream &out, int indent_level) const;