28 int ClipPlaneAttrib::_attrib_slot;
32 class ComparePlaneNodePriorities {
38 nassertr(pa !=
nullptr && pb !=
nullptr, a < b);
51 make(ClipPlaneAttrib::Operation op,
PlaneNode *plane) {
53 <<
"Using deprecated ClipPlaneAttrib interface.\n";
59 attrib = make_all_off();
74 nassert_raise(
"invalid operation");
87 <<
"Using deprecated ClipPlaneAttrib interface.\n";
93 attrib = make_all_off();
111 nassert_raise(
"invalid operation");
125 <<
"Using deprecated ClipPlaneAttrib interface.\n";
131 attrib = make_all_off();
152 nassert_raise(
"invalid operation");
166 <<
"Using deprecated ClipPlaneAttrib interface.\n";
172 attrib = make_all_off();
196 nassert_raise(
"invalid operation");
223 <<
"Using deprecated ClipPlaneAttrib interface.\n";
246 <<
"Using deprecated ClipPlaneAttrib interface.\n";
265 <<
"Using deprecated ClipPlaneAttrib interface.\n";
285 <<
"Using deprecated ClipPlaneAttrib interface.\n";
303 <<
"Using deprecated ClipPlaneAttrib interface.\n";
306 return add_on_plane(
NodePath(plane));
308 return add_off_plane(
NodePath(plane));
321 <<
"Using deprecated ClipPlaneAttrib interface.\n";
324 return remove_on_plane(
NodePath(plane));
326 return remove_off_plane(
NodePath(plane));
337 if (_empty_attrib ==
nullptr) {
341 return _empty_attrib;
352 if (_all_off_attrib ==
nullptr) {
354 attrib->_off_all_planes =
true;
355 _all_off_attrib = return_new(attrib);
358 return _all_off_attrib;
366 add_on_plane(
const NodePath &plane)
const {
369 attrib->_on_planes.insert(plane);
370 attrib->_off_planes.erase(plane);
372 std::pair<Planes::iterator, bool> insert_result =
373 attrib->_on_planes.insert(Planes::value_type(plane));
374 if (insert_result.second) {
376 attrib->_off_planes.erase(plane);
379 return return_new(attrib);
387 remove_on_plane(
const NodePath &plane)
const {
390 attrib->_on_planes.erase(plane);
391 return return_new(attrib);
399 add_off_plane(
const NodePath &plane)
const {
402 if (!_off_all_planes) {
403 attrib->_off_planes.insert(plane);
405 attrib->_on_planes.erase(plane);
406 return return_new(attrib);
414 remove_off_plane(
const NodePath &plane)
const {
417 attrib->_off_planes.erase(plane);
418 return return_new(attrib);
427 filter_to_max(
int max_clip_planes)
const {
428 if (max_clip_planes < 0 || (
int)_on_planes.
size() <= max_clip_planes) {
437 Filtered::const_iterator fi;
438 fi = _filtered.find(max_clip_planes);
439 if (fi != _filtered.end()) {
447 Planes priority_planes = _on_planes;
450 sort(priority_planes.begin(), priority_planes.end(),
451 ComparePlaneNodePriorities());
454 priority_planes.erase(priority_planes.begin() + max_clip_planes,
455 priority_planes.end());
458 priority_planes.sort();
462 attrib->_on_planes.
swap(priority_planes);
468 ((
ClipPlaneAttrib *)
this)->_filtered[max_clip_planes] = planeNode_attrib;
469 return planeNode_attrib;
484 DCAST_INTO_R(ta, other,
nullptr);
486 if (_off_all_planes || (!ta->_off_all_planes && ta->_off_planes.
empty())) {
492 if (ta->_off_all_planes || _off_planes.
empty()) {
497 Planes::const_iterator ai = _off_planes.
begin();
498 Planes::const_iterator bi = ta->_off_planes.
begin();
502 std::back_insert_iterator<Planes> result =
503 std::back_inserter(new_attrib->_on_planes);
505 while (ai != _off_planes.
end() &&
506 bi != ta->_off_planes.
end()) {
514 }
else if ((*bi) < (*ai)) {
530 while (ai != _off_planes.
end()) {
536 while (bi != ta->_off_planes.
end()) {
542 return return_new(new_attrib);
548 void ClipPlaneAttrib::
549 output(std::ostream &out)
const {
550 out << get_type() <<
":";
551 if (_off_planes.
empty()) {
552 if (_on_planes.
empty()) {
553 if (_off_all_planes) {
559 if (_off_all_planes) {
568 Planes::const_iterator fi;
569 for (fi = _off_planes.
begin(); fi != _off_planes.
end(); ++fi) {
574 if (!_on_planes.
empty()) {
579 Planes::const_iterator li;
580 for (li = _on_planes.
begin(); li != _on_planes.
end(); ++li) {
598 int ClipPlaneAttrib::
601 DCAST_INTO_R(ta, other, 0);
603 if (_off_all_planes != ta->_off_all_planes) {
604 return (
int)_off_all_planes - (int)ta->_off_all_planes;
607 Planes::const_iterator li = _on_planes.
begin();
608 Planes::const_iterator oli = ta->_on_planes.
begin();
610 while (li != _on_planes.
end() && oli != ta->_on_planes.
end()) {
623 if (li != _on_planes.
end()) {
626 if (oli != ta->_on_planes.
end()) {
630 Planes::const_iterator fi = _off_planes.
begin();
631 Planes::const_iterator ofi = ta->_off_planes.
begin();
633 while (fi != _off_planes.
end() && ofi != ta->_off_planes.
end()) {
646 if (fi != _off_planes.
end()) {
649 if (ofi != ta->_off_planes.
end()) {
662 size_t ClipPlaneAttrib::
663 get_hash_impl()
const {
666 Planes::const_iterator li;
667 for (li = _on_planes.
begin(); li != _on_planes.
end(); ++li) {
676 for (li = _off_planes.
begin(); li != _off_planes.
end(); ++li) {
698 DCAST_INTO_R(ta, other,
nullptr);
700 if (ta->_off_all_planes) {
708 Planes::const_iterator ai = _on_planes.
begin();
709 Planes::const_iterator bi = ta->_on_planes.
begin();
710 Planes::const_iterator ci = ta->_off_planes.
begin();
714 std::back_insert_iterator<Planes> result =
715 std::back_inserter(new_attrib->_on_planes);
717 while (ai != _on_planes.
end() &&
718 bi != ta->_on_planes.
end() &&
719 ci != ta->_off_planes.
end()) {
728 }
else if ((*ci) < (*ai)) {
740 }
else if ((*bi) < (*ai)) {
756 while (ai != _on_planes.
end() && bi != ta->_on_planes.
end()) {
764 }
else if ((*bi) < (*ai)) {
780 while (ai != _on_planes.
end() && ci != ta->_off_planes.
end()) {
788 }
else if ((*ci) < (*ai)) {
801 while (ai != _on_planes.
end()) {
807 while (bi != ta->_on_planes.
end()) {
813 return return_new(new_attrib);
835 void ClipPlaneAttrib::
863 Planes::const_iterator fi;
865 for (fi = _off_planes.
begin(); fi != _off_planes.
end(); ++fi) {
869 for (fi = _off_planes.
begin(); fi != _off_planes.
end(); ++fi) {
870 (*fi).write_datagram(manager, dg);
878 Planes::const_iterator nti;
880 for (nti = _on_planes.
begin(); nti != _on_planes.
end(); ++nti) {
884 for (nti = _on_planes.
begin(); nti != _on_planes.
end(); ++nti) {
885 (*nti).write_datagram(manager, dg);
899 for (
size_t i = 0; i < _off_planes.
size(); ++i) {
900 pi += _off_planes[i].complete_pointers(p_list + pi, manager);
903 for (
size_t i = 0; i < _on_planes.
size(); ++i) {
904 pi += _on_planes[i].complete_pointers(p_list + pi, manager);
909 nassertr(aux !=
nullptr, pi);
912 aux->_off_list.reserve(aux->_num_off_planes);
913 for (i = 0; i < aux->_num_off_planes; ++i) {
915 DCAST_INTO_R(node, p_list[pi++], pi);
916 aux->_off_list.push_back(node);
919 aux->_on_list.reserve(aux->_num_on_planes);
920 for (i = 0; i < aux->_num_on_planes; ++i) {
922 DCAST_INTO_R(node, p_list[pi++], pi);
923 aux->_on_list.push_back(node);
942 for (
size_t i = 0; i < _off_planes.
size(); ++i) {
950 for (
size_t i = 0; i < _on_planes.
size(); ++i) {
961 nassertv(aux !=
nullptr);
962 nassertv(aux->_num_off_planes == (
int)aux->_off_list.size());
963 nassertv(aux->_num_on_planes == (
int)aux->_on_list.size());
967 _off_planes.
reserve(aux->_off_list.size());
968 NodeList::iterator ni;
969 for (ni = aux->_off_list.begin(); ni != aux->_off_list.end(); ++ni) {
971 int n = areg->
find_node(node->get_type(), node->get_name());
981 _on_planes.
reserve(aux->_on_list.size());
982 for (ni = aux->_on_list.begin(); ni != aux->_on_list.end(); ++ni) {
984 int n = areg->
find_node(node->get_type(), node->get_name());
988 node = _on_planes.
back().node();
1013 attrib->fillin(scan, manager);
1024 void ClipPlaneAttrib::
1026 RenderAttrib::fillin(scan, manager);
1032 for (
size_t i = 0; i < _off_planes.
size(); ++i) {
1033 _off_planes[i].fillin(scan, manager);
1037 for (
size_t i = 0; i < _on_planes.
size(); ++i) {
1038 _on_planes[i].fillin(scan, manager);
1041 BamAuxData *aux =
new BamAuxData;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This global object records NodePaths that are referenced by scene graph attribs, such as ClipPlaneAtt...
int find_node(const NodePath &attrib_node) const
Returns the index number of the indicated NodePath in the registry (assuming its name hasn't changed ...
get_node
Returns the nth NodePath recorded in the registry.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void register_finalize(TypedWritable *whom)
Should be called by an object reading itself from the Bam file to indicate that this particular objec...
void read_pointers(DatagramIterator &scan, int count)
A convenience function to read a contiguous list of pointers.
void set_aux_data(TypedWritable *obj, const std::string &name, AuxData *data)
Associates an arbitrary block of data with the indicated object (or NULL), and the indicated name.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
AuxData * get_aux_data(TypedWritable *obj, const std::string &name) const
Returns the pointer previously associated with the bam reader by a previous call to set_aux_data(),...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
This functions similarly to a LightAttrib.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static void register_with_read_factory()
Tells the BamReader how to create objects of type ClipPlaneAttrib.
get_num_off_planes
Returns the number of planes that are disabled by the attribute.
bool has_all_off() const
Returns true if this attrib disables all planes (although it may also enable some).
int get_num_planes() const
Returns the number of planes listed in the attribute.
bool has_on_plane(const NodePath &plane) const
Returns true if the indicated plane is enabled by the attrib, false otherwise.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
bool has_off_plane(const NodePath &plane) const
Returns true if the indicated plane is disabled by the attrib, false otherwise.
bool has_plane(PlaneNode *plane) const
Returns true if the indicated plane is listed in the attrib, false otherwise.
PlaneNode * get_plane(int n) const
Returns the nth plane listed in the attribute.
get_on_plane
Returns the nth plane enabled by the attribute, sorted in render order.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
get_num_on_planes
Returns the number of planes that are enabled by the attribute.
Operation get_operation() const
Returns the basic operation type of the ClipPlaneAttrib.
get_off_plane
Returns the nth plane disabled by the attribute, sorted in arbitrary (pointer) order.
A class to retrieve the individual data elements previously stored in a Datagram.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
bool get_bool()
Extracts a boolean value.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_bool(bool value)
Adds a boolean value to the datagram.
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
size_t add_hash(size_t hash) const
Adds the NodePath into the running hash.
bool is_empty() const
Returns true if the NodePath contains no nodes.
PandaNode * node() const
Returns the referenced node of the path.
int compare_to(const NodePath &other) const
Returns a number less than zero if this NodePath sorts before the other one, greater than zero if it ...
A basic node of the scene graph or data graph.
A node that contains a plane.
static UpdateSeq get_sort_seq()
Returns a global sequence number that is incremented any time any PlaneNode in the world changes sort...
int get_priority() const
Returns the priority associated with this clip plane.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
TypeHandle is the identifier used to differentiate C++ class types.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Base class for objects that can be written to and read from Bam files.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
reference back()
Returns a reference to the first element.
void reserve(size_type_0 n)
Informs the vector of a planned change in size; ensures that the capacity of the vector is greater th...
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
void push_back(const value_type_0 &key)
Adds the new element to the end of the vector without regard for proper sorting.
void swap(ordered_vector< Key, Compare, Vector > &other)
Exchanges the contents of this vector and the other vector, in constant time (e.g....
size_type_0 size() const
Returns the number of elements in the ordered vector.
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
void sort()
Maps to sort_unique().
CPT(RenderAttrib) ClipPlaneAttrib
Constructs a new ClipPlaneAttrib object that enables (or disables, according to op) the indicated pla...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.