Skip to content

Commit 594e6b3

Browse files
committed
chan: add various property interfaces to animation system
1 parent 69f8f8b commit 594e6b3

8 files changed

+43
-8
lines changed

panda/src/chan/animBundle.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class EXPCL_PANDA_CHAN AnimBundle : public AnimGroup {
3838
INLINE double get_base_frame_rate() const;
3939
INLINE int get_num_frames() const;
4040

41+
MAKE_PROPERTY(base_frame_rate, get_base_frame_rate);
42+
MAKE_PROPERTY(num_frames, get_num_frames);
43+
4144
virtual void output(std::ostream &out) const;
4245

4346
protected:

panda/src/chan/animBundleNode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class EXPCL_PANDA_CHAN AnimBundleNode : public PandaNode {
4141
PUBLISHED:
4242
INLINE AnimBundle *get_bundle() const;
4343

44+
MAKE_PROPERTY(bundle, get_bundle);
45+
4446
static AnimBundle *find_anim_bundle(PandaNode *root);
4547

4648
private:

panda/src/chan/animChannelMatrixDynamic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class EXPCL_PANDA_CHAN AnimChannelMatrixDynamic : public AnimChannelMatrix {
5757
INLINE const TransformState *get_value_transform() const;
5858
INLINE PandaNode *get_value_node() const;
5959

60+
MAKE_PROPERTY(value_node, get_value_node, set_value_node);
61+
6062
protected:
6163
virtual AnimGroup *make_copy(AnimGroup *parent) const;
6264

panda/src/chan/animChannelMatrixXfmTable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class EXPCL_PANDA_CHAN AnimChannelMatrixXfmTable : public AnimChannelMatrix {
5959
INLINE bool has_table(char table_id) const;
6060
INLINE void clear_table(char table_id);
6161

62+
MAKE_MAP_PROPERTY(tables, has_table, get_table, set_table, clear_table);
63+
6264
public:
6365
virtual void write(std::ostream &out, int indent_level) const;
6466

panda/src/chan/animChannelScalarDynamic.I

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,25 @@
1010
* @author drose
1111
* @date 2003-10-20
1212
*/
13+
14+
/**
15+
* Gets the value of the channel. This will return the value explicitly
16+
* specified by set_value() unless a value node was specified using
17+
* set_value_node().
18+
*/
19+
INLINE PN_stdfloat AnimChannelScalarDynamic::
20+
get_value() const {
21+
if (_value_node != nullptr) {
22+
return _value->get_pos()[0];
23+
} else {
24+
return _float_value;
25+
}
26+
}
27+
28+
/**
29+
* Returns the node that was set via set_value_node(), if any.
30+
*/
31+
INLINE PandaNode *AnimChannelScalarDynamic::
32+
get_value_node() const {
33+
return _value_node;
34+
}

panda/src/chan/animChannelScalarDynamic.cxx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,12 @@ has_changed(int, double, int, double) {
8484
*/
8585
void AnimChannelScalarDynamic::
8686
get_value(int, PN_stdfloat &value) {
87-
if (_value_node != nullptr) {
88-
value = _value->get_pos()[0];
89-
90-
} else {
91-
value = _float_value;
92-
}
87+
value = get_value();
9388
}
9489

9590
/**
96-
* Explicitly sets the value.
91+
* Explicitly sets the value. This will remove any node assigned via
92+
* set_value_node().
9793
*/
9894
void AnimChannelScalarDynamic::
9995
set_value(PN_stdfloat value) {
@@ -104,7 +100,8 @@ set_value(PN_stdfloat value) {
104100

105101
/**
106102
* Specifies a node whose transform will be queried each frame to implicitly
107-
* specify the transform of this joint.
103+
* specify the transform of this joint. This will override the values set by
104+
* set_value().
108105
*/
109106
void AnimChannelScalarDynamic::
110107
set_value_node(PandaNode *value_node) {

panda/src/chan/animChannelScalarDynamic.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ class EXPCL_PANDA_CHAN AnimChannelScalarDynamic : public AnimChannelScalar {
4141
virtual bool has_changed(int last_frame, double last_frac,
4242
int this_frame, double this_frac);
4343
virtual void get_value(int frame, PN_stdfloat &value);
44+
INLINE PN_stdfloat get_value() const;
45+
INLINE PandaNode *get_value_node() const;
4446

4547
PUBLISHED:
4648
void set_value(PN_stdfloat value);
4749
void set_value_node(PandaNode *node);
4850

51+
MAKE_PROPERTY(value, get_value, set_value);
52+
MAKE_PROPERTY(value_node, get_value_node, set_value_node);
53+
4954
protected:
5055
virtual AnimGroup *make_copy(AnimGroup *parent) const;
5156

panda/src/chan/animChannelScalarTable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class EXPCL_PANDA_CHAN AnimChannelScalarTable : public AnimChannelScalar {
4444
INLINE bool has_table() const;
4545
INLINE void clear_table();
4646

47+
MAKE_PROPERTY2(table, has_table, get_table, set_table, clear_table);
48+
4749
public:
4850
virtual void write(std::ostream &out, int indent_level) const;
4951

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy