Panda3D
Loading...
Searching...
No Matches
eggMesherStrip.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 eggMesherStrip.I
10 * @author drose
11 * @date 2005-03-13
12 */
13
14/**
15 *
16 */
17INLINE EggMesherStrip::
18EggMesherStrip(const EggMesherStrip &copy) :
19 _prims(copy._prims),
20 _edges(copy._edges),
21 _verts(copy._verts),
22 _type(copy._type),
23 _index(copy._index),
24 _status(copy._status),
25 _planar(copy._planar),
26 _plane_normal(copy._plane_normal),
27 _plane_offset(copy._plane_offset),
28 _row_id(copy._row_id),
29 _flat_shaded(copy._flat_shaded)
30{
31}
32
33/**
34 * Returns true if the strip and the other strip are coplanar, within the
35 * indicated threshold. See coplanarity().
36 */
38is_coplanar_with(const EggMesherStrip &other, PN_stdfloat threshold) const {
39 return (coplanarity(other) <= threshold);
40}
41
42/**
43 * Returns the degree to which the two strips are coplanar. 0.0 is exactly
44 * coplanar; numbers somewhat larger than zero indicate less coplanar. 1.0 is
45 * at right angles; 2.0 is exactly backfacing. If either strip is not itself
46 * planar, 3.0 is returned.
47 */
48INLINE PN_stdfloat EggMesherStrip::
49coplanarity(const EggMesherStrip &other) const {
50 if (_planar && other._planar) {
51 return 1.0 - dot(_plane_normal, other._plane_normal);
52 }
53 return 3.0;
54}
55
56/**
57 * Returns an integer which gives a heuristic about the similarity of
58 * different strip types. In general, closer numbers are more similar.
59 */
61type_category() const {
62 switch (_type) {
63 case PT_tri:
64 return 1;
65
66 case PT_tristrip:
67 return 2;
68
69 case PT_quad:
70 case PT_quadstrip:
71 return 5;
72
73 default:
74 return 10;
75 }
76}
77
78
79/**
80 * Rotates a triangle or quad by bringing its first vertex to the back.
81 */
84 _verts.push_back(_verts.front());
85 _verts.pop_front();
86}
87
88/**
89 * Rotates a triangle or quad by bringing its last vertex to the front.
90 */
93 _verts.push_front(_verts.back());
94 _verts.pop_back();
95}
96
97
98/**
99 * Returns an EggMesherEdge which represents the leading edge in the quadstrip
100 * or tristrip. This EggMesherEdge will not have pointer equality with any
101 * shared EggMesherEdge.
102 */
104get_head_edge() const {
105 Verts::const_iterator vi = _verts.begin();
106 nassertr(vi != _verts.end(), EggMesherEdge(0, 0));
107 ++vi;
108 return EggMesherEdge(_verts.front(), *vi);
109}
110
111/**
112 * Returns an EggMesherEdge which represents the trailing edge in the
113 * quadstrip or tristrip. This EggMesherEdge will not have pointer equality
114 * with any shared EggMesherEdge.
115 */
117get_tail_edge() const {
118 Verts::const_reverse_iterator vi = _verts.rbegin();
119 nassertr(vi != _verts.rend(), EggMesherEdge(0, 0));
120 ++vi;
121 return EggMesherEdge(*vi, _verts.back());
122}
123
124/**
125 * Defines equality for strips. This actually tests only pointer equality;
126 * it's used only when removing a strip from the list.
127 */
129operator == (const EggMesherStrip &other) const {
130 return this == &other;
131}
132
133/**
134 *
135 */
136INLINE bool EggMesherStrip::
137operator != (const EggMesherStrip &other) const {
138 return !operator == (other);
139}
Represents one edge of a triangle, as used by the EggMesher to discover connected triangles.
Represents a triangle strip or quad strip in progress, as assembled by the mesher.
EggMesherEdge get_tail_edge() const
Returns an EggMesherEdge which represents the trailing edge in the quadstrip or tristrip.
void rotate_forward()
Rotates a triangle or quad by bringing its first vertex to the back.
bool is_coplanar_with(const EggMesherStrip &other, PN_stdfloat threshold) const
Returns true if the strip and the other strip are coplanar, within the indicated threshold.
bool operator==(const EggMesherStrip &other) const
Defines equality for strips.
EggMesherEdge get_head_edge() const
Returns an EggMesherEdge which represents the leading edge in the quadstrip or tristrip.
int type_category() const
Returns an integer which gives a heuristic about the similarity of different strip types.
void rotate_back()
Rotates a triangle or quad by bringing its last vertex to the front.
PN_stdfloat coplanarity(const EggMesherStrip &other) const
Returns the degree to which the two strips are coplanar.