Panda3D
Loading...
Searching...
No Matches
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
19TypeHandle EggVertexAux::_type_handle;
20
21/**
22 *
23 */
24EggVertexAux::
25EggVertexAux(const std::string &name, const LVecBase4d &aux) :
26 EggNamedObject(name),
27 _aux(aux)
28{
29}
30
31/**
32 *
33 */
34EggVertexAux::
35EggVertexAux(const EggVertexAux &copy) :
36 EggNamedObject(copy),
37 _aux(copy._aux)
38{
39}
40
41/**
42 *
43 */
44EggVertexAux &EggVertexAux::
45operator = (const EggVertexAux &copy) {
46 EggNamedObject::operator = (copy);
47 _aux = copy._aux;
48
49 return (*this);
50}
51
52/**
53 *
54 */
55EggVertexAux::
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 */
63PT(EggVertexAux) EggVertexAux::
64make_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 */
74void EggVertexAux::
75write(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 */
89compare_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}
This is a fairly low-level base class–any egg object that has a name.
The set of named auxiliary data that may or may not be assigned to a vertex.
int compare_to(const EggVertexAux &other) const
An ordering operator to compare two vertices for sorting order.
const LVecBase4d & get_aux() const
Returns the auxiliary data quadruple.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.