Panda3D
Loading...
Searching...
No Matches
unionBoundingVolume.h
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 unionBoundingVolume.h
10 * @author drose
11 * @date 2012-02-08
12 */
13
14#ifndef UNIONBOUNDINGVOLUME_H
15#define UNIONBOUNDINGVOLUME_H
16
17#include "pandabase.h"
18
20#include "pvector.h"
21
22/**
23 * This special bounding volume is the union of all of its constituent
24 * bounding volumes.
25 *
26 * A point is defined to be within a UnionBoundingVolume if it is within any
27 * one or more of its component bounding volumes.
28 */
29class EXPCL_PANDA_MATHUTIL UnionBoundingVolume : public GeometricBoundingVolume {
30PUBLISHED:
31 INLINE_MATHUTIL UnionBoundingVolume();
32 ALLOC_DELETED_CHAIN(UnionBoundingVolume);
33
34public:
36
37 virtual BoundingVolume *make_copy() const;
38
39 virtual LPoint3 get_approx_center() const;
40 virtual void xform(const LMatrix4 &mat);
41
42 virtual void output(std::ostream &out) const;
43 virtual void write(std::ostream &out, int indent_level) const;
44
45PUBLISHED:
46 INLINE_MATHUTIL int get_num_components() const;
47 INLINE_MATHUTIL const GeometricBoundingVolume *get_component(int n) const;
48 MAKE_SEQ(get_components, get_num_components, get_component);
49 MAKE_SEQ_PROPERTY(components, get_num_components, get_component);
50
51 void clear_components();
52 void add_component(const GeometricBoundingVolume *component);
53
54 void filter_intersection(const BoundingVolume *volume);
55
56protected:
57 virtual bool extend_other(BoundingVolume *other) const;
58 virtual bool around_other(BoundingVolume *other,
59 const BoundingVolume **first,
60 const BoundingVolume **last) const;
61 virtual int contains_other(const BoundingVolume *other) const;
62
63 virtual bool extend_by_geometric(const GeometricBoundingVolume *volume);
64 virtual bool around_geometric(const BoundingVolume **first,
65 const BoundingVolume **last);
66
67 virtual int contains_point(const LPoint3 &point) const;
68 virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
69 virtual int contains_sphere(const BoundingSphere *sphere) const;
70 virtual int contains_box(const BoundingBox *box) const;
71 virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
72 virtual int contains_line(const BoundingLine *line) const;
73 virtual int contains_plane(const BoundingPlane *plane) const;
74 virtual int contains_union(const UnionBoundingVolume *unionv) const;
75 virtual int contains_intersection(const IntersectionBoundingVolume *intersection) const;
76 virtual int contains_finite(const FiniteBoundingVolume *volume) const;
77 virtual int contains_geometric(const GeometricBoundingVolume *volume) const;
78 int other_contains_union(const BoundingVolume *other) const;
79
80private:
81 typedef pvector<CPT(GeometricBoundingVolume) > Components;
82 Components _components;
83
84public:
85 static TypeHandle get_class_type() {
86 return _type_handle;
87 }
88 static void init_type() {
89 GeometricBoundingVolume::init_type();
90 register_type(_type_handle, "UnionBoundingVolume",
91 GeometricBoundingVolume::get_class_type());
92 }
93 virtual TypeHandle get_type() const {
94 return get_class_type();
95 }
96 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
97
98private:
99 static TypeHandle _type_handle;
100
101 friend class BoundingVolume;
102};
103
104#include "unionBoundingVolume.I"
105
106#endif
A special kind of GeometricBoundingVolume that is known to be finite.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
void clear_components()
Removes all components from the volume.
get_num_components
Returns the number of components in the union.
void filter_intersection(const BoundingVolume *volume)
Removes from the union any components that have no intersection with the indicated volume.
void add_component(const GeometricBoundingVolume *component)
Adds a new component to the volume.
get_component
Returns the nth component in the union.
UnionBoundingVolume()
Constructs an empty union.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.