52static const PN_stdfloat dual_opaque_level = 252.0 / 256.0;
53static const double bin_color_flash_rate = 1.0;
62 _draw_region_pcollector(draw_region_pcollector)
69 _show_transparency = show_transparency.get_value();
80 PT(CullResult) new_result =
new CullResult(_gsg, _draw_region_pcollector);
81 new_result->_bins.reserve(_bins.size());
85 for (
size_t i = 0; i < _bins.size(); ++i) {
87 if (old_bin ==
nullptr ||
88 old_bin->get_bin_type() != bin_manager->
get_bin_type(i)) {
89 new_result->_bins.push_back(
nullptr);
91 new_result->_bins.push_back(old_bin->
make_next());
104 static const LColor flash_alpha_color(0.92, 0.96, 0.10, 1.0f);
105 static const LColor flash_binary_color(0.21f, 0.67f, 0.24, 1.0f);
106 static const LColor flash_multisample_color(0.78f, 0.05f, 0.81f, 1.0f);
107 static const LColor flash_dual_color(0.92, 0.01f, 0.01f, 1.0f);
109 nassertv(object->_draw_callback !=
nullptr || object->_geom !=
nullptr);
117 object->_state->get_attrib_def(rescale);
118 if (rescale->
get_mode() == RescaleNormalAttrib::M_auto) {
119 RescaleNormalAttrib::Mode mode;
121 if (object->_internal_transform->has_identity_scale()) {
122 mode = RescaleNormalAttrib::M_none;
123 }
else if (object->_internal_transform->has_uniform_scale()) {
124 mode = RescaleNormalAttrib::M_rescale;
126 mode = RescaleNormalAttrib::M_normalize;
129 object->_state =
object->_state->compose(get_rescale_normal_state(mode));
134 if (object->_state->get_attrib(rmode)) {
135 if (rmode->
get_mode() == RenderModeAttrib::M_filled_wireframe) {
138 object->_state->get_attrib(shader);
139 wireframe_part->_state = get_wireframe_overlay_state(rmode, shader);
142 (_gsg, _gsg->get_geom_munger(wireframe_part->_state, current_thread),
144 int wireframe_bin_index = bin_manager->
find_bin(
"fixed");
146 nassertv(bin !=
nullptr);
147 check_flash_bin(wireframe_part->_state, bin_manager, wireframe_bin_index);
148 bin->add_object(wireframe_part, current_thread);
150 delete wireframe_part;
153 object->_state =
object->_state->compose(get_wireframe_filled_state());
159 if (object->_state->get_attrib(trans)) {
161 case TransparencyAttrib::M_alpha:
162 case TransparencyAttrib::M_premultiplied_alpha:
165 object->_state =
object->_state->compose(get_alpha_state());
166 check_flash_transparency(object->_state, flash_alpha_color);
169 case TransparencyAttrib::M_binary:
171 object->_state =
object->_state->compose(get_binary_state());
172 check_flash_transparency(object->_state, flash_binary_color);
175 case TransparencyAttrib::M_multisample:
176 case TransparencyAttrib::M_multisample_mask:
179 if (!_gsg->get_supports_multisample()) {
180 object->_state =
object->_state->compose(get_binary_state());
182 check_flash_transparency(object->_state, flash_multisample_color);
185 case TransparencyAttrib::M_dual:
187 check_flash_transparency(object->_state, flash_dual_color);
201 if (!object->_state->get_attrib(bin_attrib) ||
206 if (m_dual_transparent)
210 CPT(
RenderState) transparent_state = get_dual_transparent_state();
211 transparent_part->_state =
object->_state->compose(transparent_state);
213 (_gsg, _gsg->get_geom_munger(transparent_part->_state, current_thread),
215 int transparent_bin_index = transparent_part->_state->get_bin_index();
217 nassertv(bin !=
nullptr);
218 check_flash_bin(transparent_part->_state, bin_manager, transparent_bin_index);
219 bin->add_object(transparent_part, current_thread);
221 delete transparent_part;
227 object->_state =
object->_state->compose(get_dual_opaque_state());
229 if (!m_dual_opaque) {
245 int bin_index =
object->_state->get_bin_index();
247 nassertv(bin !=
nullptr);
248 check_flash_bin(object->_state, bin_manager, bin_index);
252 if (object->
munge_geom(_gsg, _gsg->get_geom_munger(object->_state, current_thread), traverser, force)) {
256 bin->add_object(
object, current_thread);
271 for (
size_t i = 0; i < _bins.size(); ++i) {
279 if (bin !=
nullptr) {
291 bool force = !_gsg->get_effective_incomplete_render();
296 for (
int i = 0; i < num_bins; i++) {
297 int bin_index = bin_manager->
get_bin(i);
298 nassertv(bin_index >= 0);
300 if (bin_index < (
int)_bins.size() && _bins[bin_index] !=
nullptr) {
302 _gsg->push_group_marker(_bins[bin_index]->get_name());
303 _bins[bin_index]->draw(force, current_thread);
304 _gsg->pop_group_marker();
326 for (
int i = 0; i < num_bins; i++) {
327 int bin_index = bin_manager->
get_bin(i);
328 nassertr(bin_index >= 0,
nullptr);
330 if (bin_index < (
int)_bins.size() && _bins[bin_index] !=
nullptr) {
354make_new_bin(
int bin_index) {
357 _draw_region_pcollector);
360 if (bin_ptr !=
nullptr) {
362 while (bin_index >= (
int)_bins.size()) {
363 _bins.push_back(
nullptr);
365 nassertr(bin_index >= 0 && bin_index < (
int)_bins.size(),
nullptr);
368 std::swap(_bins[bin_index], bin);
378get_rescale_normal_state(RescaleNormalAttrib::Mode mode) {
379 static CPT(RenderState) states[RescaleNormalAttrib::M_auto + 1];
380 if (states[mode].is_null()) {
384 return states[mode].p();
393 static CPT(RenderState) state =
nullptr;
394 if (state ==
nullptr) {
407 static CPT(RenderState) state =
nullptr;
408 if (state ==
nullptr) {
421apply_flash_color(CPT(
RenderState) &state,
const LColor &flash_color) {
423 if ((cycle & 1) == 0) {
424 state = state->remove_attrib(TextureAttrib::get_class_slot());
425 state = state->remove_attrib(LightAttrib::get_class_slot());
426 state = state->remove_attrib(ColorScaleAttrib::get_class_slot());
427 state = state->remove_attrib(FogAttrib::get_class_slot());
439get_dual_transparent_state() {
440 static CPT(RenderState) state =
nullptr;
441 if (state ==
nullptr) {
456 if ((cycle & 1) == 0) {
457 static CPT(RenderState) flash_state =
nullptr;
458 if (flash_state ==
nullptr) {
468 return flash_state.p();
481get_dual_opaque_state() {
482 static CPT(RenderState) state =
nullptr;
483 if (state ==
nullptr) {
492 if ((cycle & 1) == 0) {
493 static CPT(RenderState) flash_state =
nullptr;
494 if (flash_state ==
nullptr) {
501 return flash_state.p();
514get_wireframe_filled_state() {
527 return get_wireframe_overlay_state(rmode,
nullptr);
543 if (filled_wireframe_apply_shader) {
545 ColorBlendAttrib::O_zero,
546 ColorBlendAttrib::O_constant_color,
547 ColorBlendAttrib::M_add,
548 ColorBlendAttrib::O_one,
549 ColorBlendAttrib::O_one_minus_incoming_alpha,
554 ColorBlendAttrib::O_incoming_alpha,
555 ColorBlendAttrib::O_one_minus_incoming_alpha));
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static ConstPointerTo< RenderAttrib > make(PandaCompareFunc mode, PN_stdfloat reference_alpha)
Constructs a new AlphaTestAttrib object.
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
static ConstPointerTo< RenderAttrib > make_flat(const LColor &color)
Constructs a new ColorAttrib object that indicates geometry should be rendered in the indicated color...
static ConstPointerTo< RenderAttrib > make(Mode mode)
Constructs a new ColorBlendAttrib object.
static ConstPointerTo< RenderAttrib > make(const LVecBase4 &scale)
Constructs a new ColorScaleAttrib object that indicates geometry should be scaled by the indicated fa...
Assigns geometry to a particular bin by name.
get_bin_name
Returns the name of the bin this attribute specifies.
This is a global object that maintains the collection of named CullBins in the world.
BinType get_bin_type(int bin_index) const
Returns the type of the bin with the indicated bin_index (where bin_index was retrieved by get_bin() ...
static CullBinManager * get_global_ptr()
Returns the pointer to the global CullBinManager object.
bool get_bin_active(int bin_index) const
Returns the active flag of the bin with the indicated bin_index (where bin_index was retrieved by get...
get_bin
Returns the bin_index of the nth bin in the set, where n is a number between 0 and get_num_bins().
PointerTo< CullBin > make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector)
Intended to be called by CullResult when a new CullBin pointer corresponding to the indicated bin_ind...
get_num_bins
Returns the number of bins in the world.
int find_bin(const std::string &name) const
Returns the bin_index associated with the bin of the given name, or -1 if no bin has that name.
A collection of Geoms and their associated state, for a particular scene.
virtual PointerTo< CullBin > make_next() const
Returns a newly-allocated CullBin object that contains a copy of just the subset of the data from thi...
virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread)
Called after all the geoms have been added, this indicates that the cull process is finished for this...
void add_object(CullableObject *object, const CullTraverser *traverser)
Adds the indicated CullableObject to the appropriate bin.
PointerTo< PandaNode > make_result_graph()
Returns a special scene graph constructed to represent the results of the cull.
PointerTo< CullResult > make_next() const
Returns a newly-allocated CullResult object that contains a copy of just the subset of the data from ...
void draw(Thread *current_thread)
Asks all the bins to draw themselves in the correct order.
static void bin_removed(int bin_index)
Intended to be called by CullBinManager::remove_bin(), this informs all the CullResults in the world ...
CullBin * get_bin(int bin_index)
Returns the CullBin associated with the indicated bin_index, or NULL if the bin_index is invalid.
void finish_cull(SceneSetup *scene_setup, Thread *current_thread)
Called after all the geoms have been added, this indicates that the cull process is finished for this...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Thread * get_current_thread() const
Returns the currently-executing thread object, as passed to the CullTraverser constructor.
bool get_effective_incomplete_render() const
Returns true if the cull traversal is effectively in incomplete_render state, considering both the GS...
The smallest atom of cull.
bool munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, const CullTraverser *traverser, bool force)
Uses the indicated GeomMunger to transform the geom and/or its vertices.
static ConstPointerTo< RenderAttrib > make(int offset=1)
Constructs a new DepthOffsetAttrib object that indicates the relative amount of bias to write to the ...
static ConstPointerTo< RenderAttrib > make(Mode mode)
Constructs a new DepthWriteAttrib object.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
static void update_type(ReferenceCount *ptr, TypeHandle type)
Associates the indicated type with the given pointer.
A lightweight class that represents a single element that may be timed and/or counted via stats.
A basic node of the scene graph or data graph.
Specifies how polygons are to be drawn.
static ConstPointerTo< RenderAttrib > make(Mode mode, PN_stdfloat thickness=1.0f, bool perspective=false, const LColor &wireframe_color=LColor::zero())
Constructs a new RenderModeAttrib object that specifies whether to draw polygons in the normal,...
get_perspective
Returns the perspective flag.
get_thickness
Returns the line width or point thickness.
get_wireframe_color
Returns the color that is used in M_filled_wireframe mode to distinguish the wireframe from the rest ...
get_mode
Returns the render mode.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
static ConstPointerTo< RenderState > make(const RenderAttrib *attrib, int override=0)
Returns a RenderState with one attribute set.
ConstPointerTo< RenderState > add_attrib(const RenderAttrib *attrib, int override=0) const
Returns a new RenderState object that represents the same as the source state, with the new RenderAtt...
static int get_max_priority()
Returns the maximum priority number (sometimes called override) that may be set on any node.
Specifies how polygons are to be drawn.
static ConstPointerTo< RenderAttrib > make(Mode mode)
Constructs a new RescaleNormalAttrib object that specifies whether to rescale normals to compensate f...
get_mode
Returns the render mode.
This object holds the camera position, etc., and other general setup information for rendering a part...
A thread; that is, a lightweight process.
This controls the enabling of transparency.
get_mode
Returns the transparency mode.
static ConstPointerTo< RenderAttrib > make(Mode mode)
Constructs a new TransparencyAttrib object.
TypeHandle is the identifier used to differentiate C++ class types.
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.
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.
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.