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();
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) {
280 bin->finish_cull(scene_setup, current_thread);
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) {
331 root_node->add_child(_bins[bin_index]->make_result_graph());
354make_new_bin(
int bin_index) {
356 PT(
CullBin) bin = bin_manager->make_new_bin(bin_index, _gsg,
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()) {
381 states[mode] = RenderState::make(RescaleNormalAttrib::make(mode),
382 RenderState::get_max_priority());
384 return states[mode].p();
394 if (state ==
nullptr) {
397 state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater, 0.0f));
408 if (state ==
nullptr) {
409 state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater_equal, 0.5f),
410 TransparencyAttrib::make(TransparencyAttrib::M_none),
411 RenderState::get_max_priority());
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());
428 state = state->add_attrib(ColorAttrib::make_flat(flash_color),
429 RenderState::get_max_priority());
439get_dual_transparent_state() {
441 if (state ==
nullptr) {
447 state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater, 0.0f),
448 TransparencyAttrib::make(TransparencyAttrib::M_alpha),
449 DepthWriteAttrib::make(DepthWriteAttrib::M_off),
450 RenderState::get_max_priority());
456 if ((cycle & 1) == 0) {
458 if (flash_state ==
nullptr) {
459 flash_state = state->add_attrib(ColorAttrib::make_flat(LColor(0.8f, 0.2, 0.2, 1.0f)),
460 RenderState::get_max_priority());
462 flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)),
463 RenderState::get_max_priority());
465 flash_state = flash_state->add_attrib(AlphaTestAttrib::make(AlphaTestAttrib::M_less, 1.0f),
466 RenderState::get_max_priority());
468 return flash_state.p();
481get_dual_opaque_state() {
483 if (state ==
nullptr) {
484 state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater_equal, dual_opaque_level),
485 TransparencyAttrib::make(TransparencyAttrib::M_none),
486 RenderState::get_max_priority());
492 if ((cycle & 1) == 0) {
494 if (flash_state ==
nullptr) {
495 flash_state = state->add_attrib(ColorAttrib::make_flat(LColor(0.2, 0.2, 0.8f, 1.0f)),
496 RenderState::get_max_priority());
497 flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)),
498 RenderState::get_max_priority());
501 return flash_state.p();
514get_wireframe_filled_state() {
516 RenderModeAttrib::make(RenderModeAttrib::M_filled),
517 RenderState::get_max_priority());
527 return get_wireframe_overlay_state(rmode,
nullptr);
539 DepthOffsetAttrib::make(1, 0, 0.99999f),
540 RenderModeAttrib::make(RenderModeAttrib::M_wireframe,
543 if (filled_wireframe_apply_shader) {
544 state = state->add_attrib(ColorBlendAttrib::make(ColorBlendAttrib::M_add,
545 ColorBlendAttrib::O_zero,
546 ColorBlendAttrib::O_constant_color,
547 ColorBlendAttrib::M_add,
548 ColorBlendAttrib::O_one,
549 ColorBlendAttrib::O_one_minus_incoming_alpha,
551 state = state->add_attrib(shader);
553 state = state->add_attrib(ColorBlendAttrib::make(ColorBlendAttrib::M_add,
554 ColorBlendAttrib::O_incoming_alpha,
555 ColorBlendAttrib::O_one_minus_incoming_alpha));
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_frame_time
Returns the time in seconds as of the last time tick() was called (typically, this will be as of the ...
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
get_value
Returns the variable's value.
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().
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.
This stores the result of a BinCullHandler traversal: an ordered collection of CullBins,...
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.
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.
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...
Specifies how polygons are to be drawn.
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.
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.