mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
implement BT_fixed and BT_front_to_back
This commit is contained in:
parent
d201ed16f9
commit
39bbbfb145
@ -22,6 +22,8 @@
|
|||||||
cullBin.I cullBin.h \
|
cullBin.I cullBin.h \
|
||||||
cullBinAttrib.I cullBinAttrib.h \
|
cullBinAttrib.I cullBinAttrib.h \
|
||||||
cullBinBackToFront.I cullBinBackToFront.h \
|
cullBinBackToFront.I cullBinBackToFront.h \
|
||||||
|
cullBinFixed.I cullBinFixed.h \
|
||||||
|
cullBinFrontToBack.I cullBinFrontToBack.h \
|
||||||
cullBinManager.I cullBinManager.h \
|
cullBinManager.I cullBinManager.h \
|
||||||
cullBinUnsorted.I cullBinUnsorted.h \
|
cullBinUnsorted.I cullBinUnsorted.h \
|
||||||
cullFaceAttrib.I cullFaceAttrib.h \
|
cullFaceAttrib.I cullFaceAttrib.h \
|
||||||
@ -99,6 +101,8 @@
|
|||||||
cullBin.cxx \
|
cullBin.cxx \
|
||||||
cullBinAttrib.cxx \
|
cullBinAttrib.cxx \
|
||||||
cullBinBackToFront.cxx \
|
cullBinBackToFront.cxx \
|
||||||
|
cullBinFixed.cxx \
|
||||||
|
cullBinFrontToBack.cxx \
|
||||||
cullBinManager.cxx \
|
cullBinManager.cxx \
|
||||||
cullBinUnsorted.cxx \
|
cullBinUnsorted.cxx \
|
||||||
cullFaceAttrib.cxx \
|
cullFaceAttrib.cxx \
|
||||||
@ -175,6 +179,8 @@
|
|||||||
cullBin.I cullBin.h \
|
cullBin.I cullBin.h \
|
||||||
cullBinAttrib.I cullBinAttrib.h \
|
cullBinAttrib.I cullBinAttrib.h \
|
||||||
cullBinBackToFront.I cullBinBackToFront.h \
|
cullBinBackToFront.I cullBinBackToFront.h \
|
||||||
|
cullBinFixed.I cullBinFixed.h \
|
||||||
|
cullBinFrontToBack.I cullBinFrontToBack.h \
|
||||||
cullBinManager.I cullBinManager.h \
|
cullBinManager.I cullBinManager.h \
|
||||||
cullBinUnsorted.I cullBinUnsorted.h \
|
cullBinUnsorted.I cullBinUnsorted.h \
|
||||||
cullFaceAttrib.I cullFaceAttrib.h \
|
cullFaceAttrib.I cullFaceAttrib.h \
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "cullBin.h"
|
#include "cullBin.h"
|
||||||
#include "cullBinAttrib.h"
|
#include "cullBinAttrib.h"
|
||||||
#include "cullBinBackToFront.h"
|
#include "cullBinBackToFront.h"
|
||||||
|
#include "cullBinFixed.h"
|
||||||
|
#include "cullBinFrontToBack.h"
|
||||||
#include "cullBinUnsorted.h"
|
#include "cullBinUnsorted.h"
|
||||||
#include "cullTraverser.h"
|
#include "cullTraverser.h"
|
||||||
#include "cullableObject.h"
|
#include "cullableObject.h"
|
||||||
@ -150,6 +152,8 @@ init_libpgraph() {
|
|||||||
CullBin::init_type();
|
CullBin::init_type();
|
||||||
CullBinAttrib::init_type();
|
CullBinAttrib::init_type();
|
||||||
CullBinBackToFront::init_type();
|
CullBinBackToFront::init_type();
|
||||||
|
CullBinFixed::init_type();
|
||||||
|
CullBinFrontToBack::init_type();
|
||||||
CullBinUnsorted::init_type();
|
CullBinUnsorted::init_type();
|
||||||
CullTraverser::init_type();
|
CullTraverser::init_type();
|
||||||
CullableObject::init_type();
|
CullableObject::init_type();
|
||||||
|
@ -77,6 +77,9 @@ int CullBinAttrib::
|
|||||||
compare_to_impl(const RenderAttrib *other) const {
|
compare_to_impl(const RenderAttrib *other) const {
|
||||||
const CullBinAttrib *ta;
|
const CullBinAttrib *ta;
|
||||||
DCAST_INTO_R(ta, other, 0);
|
DCAST_INTO_R(ta, other, 0);
|
||||||
|
if (_draw_order != ta->_draw_order) {
|
||||||
|
return _draw_order - ta->_draw_order;
|
||||||
|
}
|
||||||
return strcmp(_bin_name.c_str(), ta->_bin_name.c_str());
|
return strcmp(_bin_name.c_str(), ta->_bin_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
53
panda/src/pgraph/cullBinFixed.I
Normal file
53
panda/src/pgraph/cullBinFixed.I
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Filename: cullBinFixed.I
|
||||||
|
// Created by: drose (29May02)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://www.panda3d.org/license.txt .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d@yahoogroups.com .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFixed::ObjectData::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE CullBinFixed::ObjectData::
|
||||||
|
ObjectData(CullableObject *object, int draw_order) :
|
||||||
|
_object(object),
|
||||||
|
_draw_order(draw_order)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFixed::ObjectData::operator <
|
||||||
|
// Access: Public
|
||||||
|
// Description: Specifies the correct sort ordering for these
|
||||||
|
// objects.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool CullBinFixed::ObjectData::
|
||||||
|
operator < (const ObjectData &other) const {
|
||||||
|
return _draw_order < other._draw_order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFixed::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE CullBinFixed::
|
||||||
|
CullBinFixed(GraphicsStateGuardianBase *gsg) :
|
||||||
|
CullBin(gsg)
|
||||||
|
{
|
||||||
|
}
|
97
panda/src/pgraph/cullBinFixed.cxx
Normal file
97
panda/src/pgraph/cullBinFixed.cxx
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// Filename: cullBinFixed.cxx
|
||||||
|
// Created by: drose (29May02)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://www.panda3d.org/license.txt .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d@yahoogroups.com .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "cullBinFixed.h"
|
||||||
|
#include "graphicsStateGuardianBase.h"
|
||||||
|
#include "geometricBoundingVolume.h"
|
||||||
|
#include "cullableObject.h"
|
||||||
|
#include "cullHandler.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
|
TypeHandle CullBinFixed::_type_handle;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFixed::Destructor
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
CullBinFixed::
|
||||||
|
~CullBinFixed() {
|
||||||
|
Objects::iterator oi;
|
||||||
|
for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
|
||||||
|
CullableObject *object = (*oi)._object;
|
||||||
|
delete object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFixed::add_object
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Adds a geom, along with its associated state, to
|
||||||
|
// the bin for rendering.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void CullBinFixed::
|
||||||
|
add_object(CullableObject *object) {
|
||||||
|
// Determine the center of the bounding volume.
|
||||||
|
const BoundingVolume &volume = object->_geom->get_bound();
|
||||||
|
|
||||||
|
if (!volume.is_empty() &&
|
||||||
|
volume.is_of_type(GeometricBoundingVolume::get_class_type())) {
|
||||||
|
const GeometricBoundingVolume *gbv;
|
||||||
|
DCAST_INTO_V(gbv, &volume);
|
||||||
|
|
||||||
|
LPoint3f center = gbv->get_approx_center();
|
||||||
|
nassertv(object->_transform != (const TransformState *)NULL);
|
||||||
|
center = center * object->_transform->get_mat();
|
||||||
|
|
||||||
|
int draw_order = object->_state->get_draw_order();
|
||||||
|
_objects.push_back(ObjectData(object, draw_order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFixed::finish_cull
|
||||||
|
// Access: Public
|
||||||
|
// Description: Called after all the geoms have been added, this
|
||||||
|
// indicates that the cull process is finished for this
|
||||||
|
// frame and gives the bins a chance to do any
|
||||||
|
// post-processing (like sorting) before moving on to
|
||||||
|
// draw.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void CullBinFixed::
|
||||||
|
finish_cull() {
|
||||||
|
stable_sort(_objects.begin(), _objects.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFixed::draw
|
||||||
|
// Access: Public
|
||||||
|
// Description: Draws all the geoms in the bin, in the appropriate
|
||||||
|
// order.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void CullBinFixed::
|
||||||
|
draw() {
|
||||||
|
Objects::const_iterator oi;
|
||||||
|
for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
|
||||||
|
CullableObject *object = (*oi)._object;
|
||||||
|
CullHandler::draw(object, _gsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
86
panda/src/pgraph/cullBinFixed.h
Normal file
86
panda/src/pgraph/cullBinFixed.h
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
// Filename: cullBinFixed.h
|
||||||
|
// Created by: drose (29May02)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://www.panda3d.org/license.txt .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d@yahoogroups.com .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef CULLBINFIXED_H
|
||||||
|
#define CULLBINFIXED_H
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
|
||||||
|
#include "cullBin.h"
|
||||||
|
#include "geom.h"
|
||||||
|
#include "transformState.h"
|
||||||
|
#include "renderState.h"
|
||||||
|
#include "pointerTo.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : CullBinFixed
|
||||||
|
// Description : A specific kind of CullBin that sorts geometry in
|
||||||
|
// the order specified by the user-specified draw_order
|
||||||
|
// parameter. This allows precise relative ordering of
|
||||||
|
// two objects.
|
||||||
|
//
|
||||||
|
// When two or more objects are assigned the same
|
||||||
|
// draw_order, they are drawn in scene-graph order (as
|
||||||
|
// with CullBinUnsorted).
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class EXPCL_PANDA CullBinFixed : public CullBin {
|
||||||
|
public:
|
||||||
|
INLINE CullBinFixed(GraphicsStateGuardianBase *gsg);
|
||||||
|
virtual ~CullBinFixed();
|
||||||
|
|
||||||
|
virtual void add_object(CullableObject *object);
|
||||||
|
virtual void finish_cull();
|
||||||
|
virtual void draw();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class ObjectData {
|
||||||
|
public:
|
||||||
|
INLINE ObjectData(CullableObject *object, int draw_order);
|
||||||
|
INLINE bool operator < (const ObjectData &other) const;
|
||||||
|
|
||||||
|
CullableObject *_object;
|
||||||
|
int _draw_order;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef pvector<ObjectData> Objects;
|
||||||
|
Objects _objects;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
CullBin::init_type();
|
||||||
|
register_type(_type_handle, "CullBinFixed",
|
||||||
|
CullBin::get_class_type());
|
||||||
|
}
|
||||||
|
virtual TypeHandle get_type() const {
|
||||||
|
return get_class_type();
|
||||||
|
}
|
||||||
|
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static TypeHandle _type_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "cullBinFixed.I"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
53
panda/src/pgraph/cullBinFrontToBack.I
Normal file
53
panda/src/pgraph/cullBinFrontToBack.I
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Filename: cullBinFrontToBack.I
|
||||||
|
// Created by: drose (29May02)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://www.panda3d.org/license.txt .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d@yahoogroups.com .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFrontToBack::ObjectData::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE CullBinFrontToBack::ObjectData::
|
||||||
|
ObjectData(CullableObject *object, float dist) :
|
||||||
|
_object(object),
|
||||||
|
_dist(dist)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFrontToBack::ObjectData::operator <
|
||||||
|
// Access: Public
|
||||||
|
// Description: Specifies the correct sort ordering for these
|
||||||
|
// objects.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool CullBinFrontToBack::ObjectData::
|
||||||
|
operator < (const ObjectData &other) const {
|
||||||
|
return _dist < other._dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFrontToBack::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE CullBinFrontToBack::
|
||||||
|
CullBinFrontToBack(GraphicsStateGuardianBase *gsg) :
|
||||||
|
CullBin(gsg)
|
||||||
|
{
|
||||||
|
}
|
97
panda/src/pgraph/cullBinFrontToBack.cxx
Normal file
97
panda/src/pgraph/cullBinFrontToBack.cxx
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// Filename: cullBinFrontToBack.cxx
|
||||||
|
// Created by: drose (29May02)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://www.panda3d.org/license.txt .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d@yahoogroups.com .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "cullBinFrontToBack.h"
|
||||||
|
#include "graphicsStateGuardianBase.h"
|
||||||
|
#include "geometricBoundingVolume.h"
|
||||||
|
#include "cullableObject.h"
|
||||||
|
#include "cullHandler.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
|
TypeHandle CullBinFrontToBack::_type_handle;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFrontToBack::Destructor
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
CullBinFrontToBack::
|
||||||
|
~CullBinFrontToBack() {
|
||||||
|
Objects::iterator oi;
|
||||||
|
for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
|
||||||
|
CullableObject *object = (*oi)._object;
|
||||||
|
delete object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFrontToBack::add_object
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Adds a geom, along with its associated state, to
|
||||||
|
// the bin for rendering.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void CullBinFrontToBack::
|
||||||
|
add_object(CullableObject *object) {
|
||||||
|
// Determine the center of the bounding volume.
|
||||||
|
const BoundingVolume &volume = object->_geom->get_bound();
|
||||||
|
|
||||||
|
if (!volume.is_empty() &&
|
||||||
|
volume.is_of_type(GeometricBoundingVolume::get_class_type())) {
|
||||||
|
const GeometricBoundingVolume *gbv;
|
||||||
|
DCAST_INTO_V(gbv, &volume);
|
||||||
|
|
||||||
|
LPoint3f center = gbv->get_approx_center();
|
||||||
|
nassertv(object->_transform != (const TransformState *)NULL);
|
||||||
|
center = center * object->_transform->get_mat();
|
||||||
|
|
||||||
|
float distance = _gsg->compute_distance_to(center);
|
||||||
|
_objects.push_back(ObjectData(object, distance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFrontToBack::finish_cull
|
||||||
|
// Access: Public
|
||||||
|
// Description: Called after all the geoms have been added, this
|
||||||
|
// indicates that the cull process is finished for this
|
||||||
|
// frame and gives the bins a chance to do any
|
||||||
|
// post-processing (like sorting) before moving on to
|
||||||
|
// draw.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void CullBinFrontToBack::
|
||||||
|
finish_cull() {
|
||||||
|
sort(_objects.begin(), _objects.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CullBinFrontToBack::draw
|
||||||
|
// Access: Public
|
||||||
|
// Description: Draws all the geoms in the bin, in the appropriate
|
||||||
|
// order.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void CullBinFrontToBack::
|
||||||
|
draw() {
|
||||||
|
Objects::const_iterator oi;
|
||||||
|
for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
|
||||||
|
CullableObject *object = (*oi)._object;
|
||||||
|
CullHandler::draw(object, _gsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
84
panda/src/pgraph/cullBinFrontToBack.h
Normal file
84
panda/src/pgraph/cullBinFrontToBack.h
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// Filename: cullBinFrontToBack.h
|
||||||
|
// Created by: drose (29May02)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://www.panda3d.org/license.txt .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d@yahoogroups.com .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef CULLBINFRONTTOBACK_H
|
||||||
|
#define CULLBINFRONTTOBACK_H
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
|
||||||
|
#include "cullBin.h"
|
||||||
|
#include "geom.h"
|
||||||
|
#include "transformState.h"
|
||||||
|
#include "renderState.h"
|
||||||
|
#include "pointerTo.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : CullBinFrontToBack
|
||||||
|
// Description : A specific kind of CullBin that sorts geometry in
|
||||||
|
// order from nearest to furthest based on the center of
|
||||||
|
// its bounding volume.
|
||||||
|
//
|
||||||
|
// This is useful for rendering opaque geometry, taking
|
||||||
|
// optimal advantage of a hierarchical Z-buffer.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class EXPCL_PANDA CullBinFrontToBack : public CullBin {
|
||||||
|
public:
|
||||||
|
INLINE CullBinFrontToBack(GraphicsStateGuardianBase *gsg);
|
||||||
|
virtual ~CullBinFrontToBack();
|
||||||
|
|
||||||
|
virtual void add_object(CullableObject *object);
|
||||||
|
virtual void finish_cull();
|
||||||
|
virtual void draw();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class ObjectData {
|
||||||
|
public:
|
||||||
|
INLINE ObjectData(CullableObject *object, float dist);
|
||||||
|
INLINE bool operator < (const ObjectData &other) const;
|
||||||
|
|
||||||
|
CullableObject *_object;
|
||||||
|
float _dist;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef pvector<ObjectData> Objects;
|
||||||
|
Objects _objects;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
CullBin::init_type();
|
||||||
|
register_type(_type_handle, "CullBinFrontToBack",
|
||||||
|
CullBin::get_class_type());
|
||||||
|
}
|
||||||
|
virtual TypeHandle get_type() const {
|
||||||
|
return get_class_type();
|
||||||
|
}
|
||||||
|
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static TypeHandle _type_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "cullBinFrontToBack.I"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "cullBinManager.h"
|
#include "cullBinManager.h"
|
||||||
#include "cullBinBackToFront.h"
|
#include "cullBinBackToFront.h"
|
||||||
|
#include "cullBinFrontToBack.h"
|
||||||
|
#include "cullBinFixed.h"
|
||||||
#include "cullBinUnsorted.h"
|
#include "cullBinUnsorted.h"
|
||||||
#include "renderState.h"
|
#include "renderState.h"
|
||||||
#include "cullResult.h"
|
#include "cullResult.h"
|
||||||
@ -203,6 +205,12 @@ make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg) {
|
|||||||
case BT_back_to_front:
|
case BT_back_to_front:
|
||||||
return new CullBinBackToFront(gsg);
|
return new CullBinBackToFront(gsg);
|
||||||
|
|
||||||
|
case BT_front_to_back:
|
||||||
|
return new CullBinFrontToBack(gsg);
|
||||||
|
|
||||||
|
case BT_fixed:
|
||||||
|
return new CullBinFixed(gsg);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new CullBinUnsorted(gsg);
|
return new CullBinUnsorted(gsg);
|
||||||
}
|
}
|
||||||
@ -313,6 +321,12 @@ parse_bin_type(const string &bin_type) {
|
|||||||
} else if (cmp_nocase_uh(bin_type, "backtofront") == 0) {
|
} else if (cmp_nocase_uh(bin_type, "backtofront") == 0) {
|
||||||
return BT_back_to_front;
|
return BT_back_to_front;
|
||||||
|
|
||||||
|
} else if (cmp_nocase_uh(bin_type, "front_to_back") == 0) {
|
||||||
|
return BT_front_to_back;
|
||||||
|
|
||||||
|
} else if (cmp_nocase_uh(bin_type, "fronttoback") == 0) {
|
||||||
|
return BT_front_to_back;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return BT_invalid;
|
return BT_invalid;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ PUBLISHED:
|
|||||||
BT_unsorted,
|
BT_unsorted,
|
||||||
BT_state_sorted,
|
BT_state_sorted,
|
||||||
BT_back_to_front,
|
BT_back_to_front,
|
||||||
|
BT_front_to_back,
|
||||||
BT_fixed,
|
BT_fixed,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1435,7 +1435,7 @@ string NodePath::
|
|||||||
get_bin_name() const {
|
get_bin_name() const {
|
||||||
nassertr_always(!is_empty(), string());
|
nassertr_always(!is_empty(), string());
|
||||||
const RenderAttrib *attrib =
|
const RenderAttrib *attrib =
|
||||||
node()->get_attrib(ColorAttrib::get_class_type());
|
node()->get_attrib(CullBinAttrib::get_class_type());
|
||||||
if (attrib != (const RenderAttrib *)NULL) {
|
if (attrib != (const RenderAttrib *)NULL) {
|
||||||
const CullBinAttrib *ba = DCAST(CullBinAttrib, attrib);
|
const CullBinAttrib *ba = DCAST(CullBinAttrib, attrib);
|
||||||
return ba->get_bin_name();
|
return ba->get_bin_name();
|
||||||
@ -1456,7 +1456,7 @@ int NodePath::
|
|||||||
get_bin_draw_order() const {
|
get_bin_draw_order() const {
|
||||||
nassertr_always(!is_empty(), false);
|
nassertr_always(!is_empty(), false);
|
||||||
const RenderAttrib *attrib =
|
const RenderAttrib *attrib =
|
||||||
node()->get_attrib(ColorAttrib::get_class_type());
|
node()->get_attrib(CullBinAttrib::get_class_type());
|
||||||
if (attrib != (const RenderAttrib *)NULL) {
|
if (attrib != (const RenderAttrib *)NULL) {
|
||||||
const CullBinAttrib *ba = DCAST(CullBinAttrib, attrib);
|
const CullBinAttrib *ba = DCAST(CullBinAttrib, attrib);
|
||||||
return ba->get_draw_order();
|
return ba->get_draw_order();
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include "cullBin.cxx"
|
#include "cullBin.cxx"
|
||||||
#include "cullBinAttrib.cxx"
|
#include "cullBinAttrib.cxx"
|
||||||
#include "cullBinBackToFront.cxx"
|
#include "cullBinBackToFront.cxx"
|
||||||
|
#include "cullBinFixed.cxx"
|
||||||
|
#include "cullBinFrontToBack.cxx"
|
||||||
#include "cullBinManager.cxx"
|
#include "cullBinManager.cxx"
|
||||||
#include "cullBinUnsorted.cxx"
|
#include "cullBinUnsorted.cxx"
|
||||||
#include "cullFaceAttrib.cxx"
|
#include "cullFaceAttrib.cxx"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user