Panda3D

Loading...
Searching...
No Matches
eggAttributes.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file eggAttributes.I
10 * @author drose
11 * @date 1999-01-16
12 */
13
14/**
15 *
16 */
17INLINE bool EggAttributes::
18has_normal() const {
19 return (_flags & F_has_normal) != 0;
20}
21
22/**
23 *
24 */
25INLINE const LNormald &EggAttributes::
26get_normal() const {
27 nassertr(has_normal(), _normal);
28 return _normal;
29}
30
31/**
32 *
33 */
34INLINE void EggAttributes::
35set_normal(const LNormald &normal) {
36 _normal = normal;
37 _flags |= F_has_normal;
38}
39
40/**
41 *
42 */
43INLINE void EggAttributes::
44clear_normal() {
45 _flags &= ~F_has_normal;
46}
47
48/**
49 * Returns true if this normal matches that of the other EggAttributes object,
50 * include the morph list.
51 */
52INLINE bool EggAttributes::
53 matches_normal(const EggAttributes &other) const {
54 if (((_flags ^ other._flags) & F_has_normal) != 0) {
55 return false;
56 }
57 if (!has_normal()) {
58 return true;
59 }
60 return (get_normal() == other.get_normal() &&
61 _dnormals.compare_to(other._dnormals, egg_parameters->_normal_threshold) == 0);
62}
63
64/**
65 * Sets this normal to be the same as the other's, include morphs. If the
66 * other has no normal, this clears the normal.
67 */
68INLINE void EggAttributes::
69 copy_normal(const EggAttributes &other) {
70 if (!other.has_normal()) {
71 clear_normal();
72 } else {
73 set_normal(other.get_normal());
74 _dnormals = other._dnormals;
75 }
76}
77
78/**
79 *
80 */
81INLINE bool EggAttributes::
82has_color() const {
83 return (_flags & F_has_color) != 0;
84}
85
86/**
87 * Returns the color set on this particular attribute. If there is no color
88 * set, returns white.
89 */
90INLINE LColor EggAttributes::
91 get_color() const {
92 if (has_color()) {
93 return _color;
94 } else {
95 return LColor(1.0, 1.0, 1.0, 1.0);
96 }
97}
98
99/**
100 *
101 */
102INLINE void EggAttributes::
103set_color(const LColor &color) {
104 _color = color;
105 _flags |= F_has_color;
106}
107
108/**
109 *
110 */
111INLINE void EggAttributes::
112clear_color() {
113 _flags &= ~F_has_color;
114}
115
116/**
117 * Returns true if this color matches that of the other EggAttributes object,
118 * include the morph list.
119 */
120INLINE bool EggAttributes::
121 matches_color(const EggAttributes &other) const {
122 if (((_flags ^ other._flags) & F_has_color) != 0) {
123 return false;
124 }
125 if (!has_color()) {
126 return true;
127 }
128 return (get_color() == other.get_color() &&
129 _drgbas.compare_to(other._drgbas, egg_parameters->_color_threshold) == 0);
130}
131
132/**
133 * Sets this color to be the same as the other's, include morphs. If the
134 * other has no color, this clears the color.
135 */
136INLINE void EggAttributes::
137 copy_color(const EggAttributes &other) {
138 if (!other.has_color()) {
139 clear_color();
140 } else {
141 set_color(other.get_color());
142 _drgbas = other._drgbas;
143 }
144}
145
146/**
147 * An ordering operator to compare two vertices for sorting order. This
148 * imposes an arbitrary ordering useful to identify unique vertices.
149 */
150INLINE bool EggAttributes::
151 sorts_less_than(const EggAttributes &other) const {
152 return compare_to(other) < 0;
153}
EggAttributes::matches_normal
bool matches_normal(const EggAttributes &other) const
Returns true if this normal matches that of the other EggAttributes object, include the morph list.
Definition eggAttributes.I:53
EggAttributes::copy_normal
void copy_normal(const EggAttributes &other)
Sets this normal to be the same as the other's, include morphs.
Definition eggAttributes.I:69
EggAttributes::compare_to
int compare_to(const EggAttributes &other) const
An ordering operator to compare two vertices for sorting order.
Definition eggAttributes.cxx:96
EggAttributes::copy_color
void copy_color(const EggAttributes &other)
Sets this color to be the same as the other's, include morphs.
Definition eggAttributes.I:137
EggAttributes::get_color
LColor get_color() const
Returns the color set on this particular attribute.
Definition eggAttributes.I:91
EggAttributes::matches_color
bool matches_color(const EggAttributes &other) const
Returns true if this color matches that of the other EggAttributes object, include the morph list.
Definition eggAttributes.I:121
EggAttributes::sorts_less_than
bool sorts_less_than(const EggAttributes &other) const
An ordering operator to compare two vertices for sorting order.
Definition eggAttributes.I:151