Panda3D
eggVertexAux.cxx
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 eggVertexAux.cxx
10  * @author jenes
11  * @date 2011-11-15
12  */
13 
14 #include "eggVertexAux.h"
15 #include "eggParameters.h"
16 
17 #include "indent.h"
18 
19 TypeHandle EggVertexAux::_type_handle;
20 
21 /**
22  *
23  */
24 EggVertexAux::
25 EggVertexAux(const std::string &name, const LVecBase4d &aux) :
26  EggNamedObject(name),
27  _aux(aux)
28 {
29 }
30 
31 /**
32  *
33  */
34 EggVertexAux::
35 EggVertexAux(const EggVertexAux &copy) :
36  EggNamedObject(copy),
37  _aux(copy._aux)
38 {
39 }
40 
41 /**
42  *
43  */
44 EggVertexAux &EggVertexAux::
45 operator = (const EggVertexAux &copy) {
46  EggNamedObject::operator = (copy);
47  _aux = copy._aux;
48 
49  return (*this);
50 }
51 
52 /**
53  *
54  */
55 EggVertexAux::
56 ~EggVertexAux() {
57 }
58 
59 /**
60  * Creates a new EggVertexAux that contains the averaged values of the two
61  * given objects. It is an error if they don't have the same name.
62  */
63 PT(EggVertexAux) EggVertexAux::
64 make_average(const EggVertexAux *first, const EggVertexAux *second) {
65  nassertr(first->get_name() == second->get_name(), nullptr);
66 
67  LVecBase4d aux = (first->_aux + second->_aux) / 2;
68  return new EggVertexAux(first->get_name(), aux);
69 }
70 
71 /**
72  *
73  */
74 void EggVertexAux::
75 write(std::ostream &out, int indent_level) const {
76  std::string inline_name = get_name();
77  if (!inline_name.empty()) {
78  inline_name += ' ';
79  }
80  indent(out, indent_level)
81  << "<Aux> " << inline_name << "{ " << get_aux() << " }\n";
82 }
83 
84 /**
85  * An ordering operator to compare two vertices for sorting order. This
86  * imposes an arbitrary ordering useful to identify unique vertices.
87  */
89 compare_to(const EggVertexAux &other) const {
90  int compare;
91  compare = _aux.compare_to(other._aux, egg_parameters->_pos_threshold);
92  if (compare != 0) {
93  return compare;
94  }
95 
96  return 0;
97 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int compare_to(const EggVertexAux &other) const
An ordering operator to compare two vertices for sorting order.
PT(EggVertexAux) EggVertexAux
Creates a new EggVertexAux that contains the averaged values of the two given objects.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
The set of named auxiliary data that may or may not be assigned to a vertex.
Definition: eggVertexAux.h:30
This is a fairly low-level base class–any egg object that has a name.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const LVecBase4d & get_aux() const
Returns the auxiliary data quadruple.
Definition: eggVertexAux.I:26