00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "config_pgraph.h"
00016
00017 #include "alphaTestAttrib.h"
00018 #include "audioVolumeAttrib.h"
00019 #include "auxBitplaneAttrib.h"
00020 #include "antialiasAttrib.h"
00021 #include "auxSceneData.h"
00022 #include "billboardEffect.h"
00023 #include "camera.h"
00024 #include "clipPlaneAttrib.h"
00025 #include "colorAttrib.h"
00026 #include "colorBlendAttrib.h"
00027 #include "colorScaleAttrib.h"
00028 #include "colorWriteAttrib.h"
00029 #include "compassEffect.h"
00030 #include "cullFaceAttrib.h"
00031 #include "cullBin.h"
00032 #include "cullBinAttrib.h"
00033 #include "cullResult.h"
00034 #include "cullTraverser.h"
00035 #include "cullableObject.h"
00036 #include "decalEffect.h"
00037 #include "depthOffsetAttrib.h"
00038 #include "depthTestAttrib.h"
00039 #include "depthWriteAttrib.h"
00040 #include "eventStorePandaNode.h"
00041 #include "findApproxLevelEntry.h"
00042 #include "fog.h"
00043 #include "fogAttrib.h"
00044 #include "geomDrawCallbackData.h"
00045 #include "geomNode.h"
00046 #include "geomTransformer.h"
00047 #include "lensNode.h"
00048 #include "light.h"
00049 #include "lightAttrib.h"
00050 #include "lightRampAttrib.h"
00051 #include "loader.h"
00052 #include "loaderFileType.h"
00053 #include "loaderFileTypeBam.h"
00054 #include "loaderFileTypeRegistry.h"
00055 #include "materialAttrib.h"
00056 #include "modelFlattenRequest.h"
00057 #include "modelLoadRequest.h"
00058 #include "modelNode.h"
00059 #include "modelRoot.h"
00060 #include "nodePath.h"
00061 #include "nodePathComponent.h"
00062 #include "pandaNode.h"
00063 #include "planeNode.h"
00064 #include "polylightEffect.h"
00065 #include "polylightNode.h"
00066 #include "portalNode.h"
00067 #include "occluderEffect.h"
00068 #include "occluderNode.h"
00069 #include "portalClipper.h"
00070 #include "renderAttrib.h"
00071 #include "renderEffect.h"
00072 #include "renderEffects.h"
00073 #include "renderModeAttrib.h"
00074 #include "renderState.h"
00075 #include "rescaleNormalAttrib.h"
00076 #include "sceneSetup.h"
00077 #include "scissorAttrib.h"
00078 #include "scissorEffect.h"
00079 #include "shadeModelAttrib.h"
00080 #include "shaderInput.h"
00081 #include "shaderAttrib.h"
00082 #include "shader.h"
00083 #include "showBoundsEffect.h"
00084 #include "stencilAttrib.h"
00085 #include "stateMunger.h"
00086 #include "texMatrixAttrib.h"
00087 #include "texProjectorEffect.h"
00088 #include "textureAttrib.h"
00089 #include "texGenAttrib.h"
00090 #include "transformState.h"
00091 #include "transparencyAttrib.h"
00092
00093 #include "dconfig.h"
00094
00095 ConfigureDef(config_pgraph);
00096 NotifyCategoryDef(pgraph, "");
00097 NotifyCategoryDef(loader, "");
00098 NotifyCategoryDef(portal, "");
00099
00100 ConfigureFn(config_pgraph) {
00101 init_libpgraph();
00102 }
00103
00104 ConfigVariableBool fake_view_frustum_cull
00105 ("fake-view-frustum-cull", false,
00106 PRC_DESC("Set this true to cause culling to be performed by rendering the "
00107 "object in red wireframe, rather than actually culling it. This "
00108 "helps make culling errors obvious."));
00109
00110 ConfigVariableBool clip_plane_cull
00111 ("clip-plane-cull", true,
00112 PRC_DESC("This is normally true; set it false to disable culling of objects "
00113 "that are completely behind one or more clip planes (primarily "
00114 "useful for debugging) This also disables the use of occluders."));
00115
00116 ConfigVariableBool allow_portal_cull
00117 ("allow-portal-cull", false,
00118 PRC_DESC("Set this true to enable portal clipping. This will enable the "
00119 "renderer to cull more objects that are clipped if not in the "
00120 "current list of portals. This is still somewhat experimental."));
00121
00122 ConfigVariableBool debug_portal_cull
00123 ("debug-portal-cull", false,
00124 PRC_DESC("Set this true to enable debug visualization during portal clipping."
00125 "(You first need to enable portal culling, using the allow-portal-cull"
00126 "variable.)"));
00127
00128 ConfigVariableBool show_occluder_volumes
00129 ("show-occluder-volumes", false,
00130 PRC_DESC("Set this true to enable debug visualization of the volumes used "
00131 "to cull objects behind an occluder."));
00132
00133 ConfigVariableBool unambiguous_graph
00134 ("unambiguous-graph", false,
00135 PRC_DESC("Set this true to make ambiguous path warning messages generate an "
00136 "assertion failure instead of just a warning (which can then be "
00137 "trapped with assert-abort)."));
00138
00139 ConfigVariableBool detect_graph_cycles
00140 ("detect-graph-cycles", true,
00141 PRC_DESC("Set this true to attempt to detect cycles in the scene graph "
00142 "(e.g. a node which is its own parent) as soon as they are "
00143 "made. This has no effect in NDEBUG mode."));
00144
00145 ConfigVariableBool no_unsupported_copy
00146 ("no-unsupported-copy", false,
00147 PRC_DESC("Set this true to make an attempt to copy an unsupported type "
00148 "generate an assertion failure instead of just a warning (which "
00149 "can then be trapped with assert-abort)."));
00150
00151 ConfigVariableBool allow_unrelated_wrt
00152 ("allow-unrelated-wrt", true,
00153 PRC_DESC("Set this true to allow unrelated NodePaths (that is, nodes which "
00154 "have no common ancestor) to be adjusted relative to each other. If "
00155 "true, these will be treated as if they had a common node above "
00156 "their top nodes."));
00157
00158 ConfigVariableBool paranoid_compose
00159 ("paranoid-compose", false,
00160 PRC_DESC("Set this true to double-check the componentwise transform compose "
00161 "(or invert) operation against the equivalent matrix-based "
00162 "operation. This has no effect if NDEBUG is defined."));
00163
00164 ConfigVariableBool compose_componentwise
00165 ("compose-componentwise", true,
00166 PRC_DESC("Set this true to perform componentwise compose and invert "
00167 "operations when possible. If this is false, the compositions "
00168 "are always computed by matrix."));
00169
00170 ConfigVariableBool uniquify_matrix
00171 ("uniquify-matrix", true,
00172 PRC_DESC("Set this true to look up arbitarary 4x4 transform matrices in the "
00173 "cache, to ensure that two differently-computed transforms that "
00174 "happen to encode the same matrix will be "
00175 "collapsed into a single pointer. Nowadays, "
00176 "with the transforms stored in a hashtable, we're generally better "
00177 "off with this set true."));
00178
00179 ConfigVariableBool paranoid_const
00180 ("paranoid-const", false,
00181 PRC_DESC("Set this true to double-check that nothing is inappropriately "
00182 "modifying the supposedly const structures like RenderState, "
00183 "RenderAttrib, TransformState, and RenderEffect. This has no effect "
00184 "if NDEBUG is defined."));
00185
00186 ConfigVariableBool auto_break_cycles
00187 ("auto-break-cycles", true,
00188 PRC_DESC("Set this true to automatically detect and break reference-count "
00189 "cycles in the TransformState and RenderState caches. When this "
00190 "is false, you must explicitly call TransformState.clear_cache() "
00191 "from time to time to prevent gradual memory bloat."));
00192
00193 ConfigVariableBool garbage_collect_states
00194 ("garbage-collect-states", true,
00195 PRC_DESC("Set this true to defer destruction of TransformState and "
00196 "RenderState objects until the end of the frame (or whenever "
00197 "TransformState::garbage_collect() and RenderState::garbage_collect() "
00198 "are called). This is a particularly useful thing to do when "
00199 "using multiple threads, because it improves parallelization."));
00200
00201 ConfigVariableDouble garbage_collect_states_rate
00202 ("garbage-collect-states-rate", 1.0,
00203 PRC_DESC("The fraction of the total number of TransformStates "
00204 "(or RenderStates, or whatever) that are processed with "
00205 "each garbage collection step. Setting this smaller than "
00206 "1.0 will collect fewer states each frame, which may require "
00207 "less processing time, but risks getting unstable cache "
00208 "performance if states accumulate faster than they can be "
00209 "cleaned up."));
00210
00211 ConfigVariableBool transform_cache
00212 ("transform-cache", true,
00213 PRC_DESC("Set this true to enable the cache of TransformState objects. "
00214 "Using the cache saves time computing transforms and inverse "
00215 "transforms, but imposes some overhead for maintaining the "
00216 "cache itself."));
00217
00218 ConfigVariableBool state_cache
00219 ("state-cache", true,
00220 PRC_DESC("Set this true to enable the cache of RenderState objects, "
00221 "similar to the TransformState cache controlled via "
00222 "transform-cache."));
00223
00224 ConfigVariableBool uniquify_transforms
00225 ("uniquify-transforms", true,
00226 PRC_DESC("Set this true to ensure that equivalent TransformStates "
00227 "are pointerwise equal. This may improve caching performance, "
00228 "but also adds additional overhead to maintain the cache, "
00229 "including the need to check for a composition cycle in "
00230 "the cache."));
00231
00232 ConfigVariableBool uniquify_states
00233 ("uniquify-states", true,
00234 PRC_DESC("Set this true to ensure that equivalent RenderStates "
00235 "are pointerwise equal. This may improve caching performance, "
00236 "but also adds additional overhead to maintain the cache, "
00237 "including the need to check for a composition cycle in "
00238 "the cache."));
00239
00240 ConfigVariableBool uniquify_attribs
00241 ("uniquify-attribs", true,
00242 PRC_DESC("Set this true to ensure that equivalent RenderAttribs "
00243 "are pointerwise equal. This may improve caching performance, "
00244 "but also adds additional overhead to maintain the cache, "
00245 "including the need to check for a composition cycle in "
00246 "the cache."));
00247
00248 ConfigVariableBool retransform_sprites
00249 ("retransform-sprites", true,
00250 PRC_DESC("To render sprite-based particle effects, Panda must convert "
00251 "the sprite points from object space into clip space, and compute "
00252 "the corners of the quads in clip space. When this variable is "
00253 "false, the resulting quads are then sent to the graphics "
00254 "hardware in clip space. When this is true, the quads are "
00255 "re-transformed back into the original object space, which is "
00256 "necessary in order for fog to work correctly on the sprites."));
00257
00258 ConfigVariableBool support_fade_lod
00259 ("support-fade-lod", true,
00260 PRC_DESC("Set this false to make FadeLOD nodes behave like regular LOD nodes "
00261 "(ignoring the fade time). This may be useful, for instance, to "
00262 "test the performance impact of using FadeLOD nodes."));
00263
00264 ConfigVariableBool depth_offset_decals
00265 ("depth-offset-decals", false,
00266 PRC_DESC("Set this true to allow decals to be implemented via the advanced "
00267 "depth offset feature, if supported, instead of via the traditional "
00268 "(and slower) two-pass approach. This is false by default "
00269 "because it appears that many graphics drivers have issues with "
00270 "their depth offset implementation."));
00271
00272 ConfigVariableInt max_collect_vertices
00273 ("max-collect-vertices", 65535,
00274 PRC_DESC("Specifies the maximum number of vertices that are allowed to be "
00275 "accumulated into any one GeomVertexData structure as a result "
00276 "of collecting objects together during a flatten operation. "
00277 "This prevents the accidental generation of large vertex buffers "
00278 "from lots of smaller vertex buffers, while not "
00279 "imposing a limit on the original size of any one "
00280 "GeomVertexData structure."));
00281
00282 ConfigVariableInt max_collect_indices
00283 ("max-collect-indices", 65535,
00284 PRC_DESC("Specifies the maximum number of vertex indices that are allowed "
00285 "to be accumulated into any one GeomPrimitive as a result "
00286 "of collecting objects together during a flatten operation. "
00287 "This prevents the accidental generation of large index buffers "
00288 "from lots of smaller index buffers, while not "
00289 "imposing a limit on the original size of any one "
00290 "GeomPrimitive."));
00291
00292 ConfigVariableBool premunge_data
00293 ("premunge-data", true,
00294 PRC_DESC("Set this true to preconvert vertex data at model load time to "
00295 "match the data requirements of the current GSG. For instance, "
00296 "color columns are pre-converted to match OpenGL or DirectX "
00297 "encoding requirements, as appropriate. When this is false, the "
00298 "data will be munged at render time instead."));
00299
00300 ConfigVariableBool preserve_geom_nodes
00301 ("preserve-geom-nodes", false,
00302 PRC_DESC("This specifies the default value for the \"preserved\" flag on "
00303 "every GeomNode created. When this is true, GeomNodes will not "
00304 "be flattened, so setting this true effectively disables the "
00305 "use of flatten to combine GeomNodes."));
00306
00307 ConfigVariableBool flatten_geoms
00308 ("flatten-geoms", true,
00309 PRC_DESC("When this is true (the default), NodePath::flatten_strong() and "
00310 "flatten_medium() will attempt to combine multiple Geoms into "
00311 "as few Geoms as possible, by combing GeomVertexDatas and then "
00312 "unifying. Setting this false disables this behavior, so that "
00313 "NodePath flatten operations will only reduce nodes. This affects "
00314 "only the NodePath interfaces; you may still make the lower-level "
00315 "SceneGraphReducer calls directly."));
00316
00317 ConfigVariableInt max_lenses
00318 ("max-lenses", 100,
00319 PRC_DESC("Specifies an upper limit on the maximum number of lenses "
00320 "and the maximum lens index number) that may be associated with "
00321 "a single LensNode. There is no technical reason for this "
00322 "limitation, but very large numbers are probably a mistake, so "
00323 "this can be used as a simple sanity check. Set it larger or "
00324 "smaller to suit your needs."));
00325
00326 ConfigVariableBool default_antialias_enable
00327 ("default-antialias-enable", false,
00328 PRC_DESC("Set this true to enable the M_auto antialiasing mode for all "
00329 "nodes by default."));
00330
00331 ConfigVariableBool polylight_info
00332 ("polylight-info", false,
00333 PRC_DESC("Set this true to view some info statements regarding the polylight. "
00334 "It is helpful for debugging."));
00335
00336 ConfigVariableDouble lod_fade_time
00337 ("lod-fade-time", 0.5,
00338 PRC_DESC("The default amount of time (in seconds) over which a FadeLODNode "
00339 "transitions between its different levels."));
00340
00341 ConfigVariableString lod_fade_bin_name
00342 ("lod-fade-bin-name", "fixed",
00343 PRC_DESC("The default bin name in which to place the fading part of a "
00344 "FadeLODNode transition."));
00345
00346 ConfigVariableInt lod_fade_bin_draw_order
00347 ("lod-fade-bin-draw-order", 0,
00348 PRC_DESC("The default bin draw order to assign the fading part of a "
00349 "FadeLODNode transition."));
00350
00351 ConfigVariableInt lod_fade_state_override
00352 ("lod-fade-state-override", 1000,
00353 PRC_DESC("The default override value to assign to the fade attribs "
00354 "in order to effect a FadeLODNode transition."));
00355
00356 ConfigVariableBool verify_lods
00357 ("verify-lods", false,
00358 PRC_DESC("When this is true, LODNodes will test when they are rendered to "
00359 "ensure that each child's geometry fits entirely within the radius "
00360 "defined by its switch-out distance. When it is false, LODNodes "
00361 "may have any switch in and out distances, regardless of the "
00362 "actual size of their geometry. This test is only made in NDEBUG "
00363 "mode (the variable is ignored in a production build)."));
00364
00365 ConfigVariableBool show_vertex_animation
00366 ("show-vertex-animation", false,
00367 PRC_DESC("Set this true to flash any objects whose vertices are animated "
00368 "by Panda on the CPU (flash red) or by hardware (flash blue). "
00369 "This only has effect when NDEBUG is not defined."));
00370
00371 ConfigVariableBool show_transparency
00372 ("show-transparency", false,
00373 PRC_DESC("Set this true to flash any objects that are rendered in "
00374 "some transparency mode. The color chosen is based on the "
00375 "particular transparency mode in effect. This only has effect "
00376 "when NDEBUG is not defined."));
00377
00378 ConfigVariableBool m_dual
00379 ("m-dual", true,
00380 PRC_DESC("Set this false to disable TransparencyAttrib::M_dual altogether "
00381 "(and use M_alpha in its place)."));
00382
00383 ConfigVariableBool m_dual_opaque
00384 ("m-dual-opaque", true,
00385 PRC_DESC("Set this false to disable just the opaque part of M_dual."));
00386
00387 ConfigVariableBool m_dual_transparent
00388 ("m-dual-transparent", true,
00389 PRC_DESC("Set this false to disable just the transparent part of M_dual."));
00390
00391 ConfigVariableBool m_dual_flash
00392 ("m-dual-flash", false,
00393 PRC_DESC("Set this true to flash any objects that use M_dual, for debugging."));
00394
00395 ConfigVariableList load_file_type
00396 ("load-file-type",
00397 PRC_DESC("List the model loader modules that Panda will automatically "
00398 "import when a new, unknown model type is loaded. This may be "
00399 "either the name of a module, or a space-separate list of filename "
00400 "extensions, followed by the name of the module."));
00401
00402 ConfigVariableString default_model_extension
00403 ("default-model-extension", "",
00404 PRC_DESC("This specifies the filename extension (with leading dot) that "
00405 "should be assumed if an attempt is made to load a filename that "
00406 "has no extension. This is primarily designed to support legacy "
00407 "code that used the now-deprecated implicit-extension feature of "
00408 "Panda's loader; new code should probably give the correct name "
00409 "for each model file they intend to load."));
00410
00411 ConfigVariableBool allow_live_flatten
00412 ("allow-live-flatten", true,
00413 PRC_DESC("Set this true to allow the use of flatten_strong() or any "
00414 "variant on a node that is attached to a live scene graph node, "
00415 "or false to disallow this. Flattening a live scene graph node "
00416 "can cause problems when threading is enabled. This variable "
00417 "only has an effect when Panda is not compiled for a release "
00418 "build."));
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428 void
00429 init_libpgraph() {
00430 static bool initialized = false;
00431 if (initialized) {
00432 return;
00433 }
00434 initialized = true;
00435
00436 AlphaTestAttrib::init_type();
00437 AntialiasAttrib::init_type();
00438 AudioVolumeAttrib::init_type();
00439 AuxBitplaneAttrib::init_type();
00440 AuxSceneData::init_type();
00441 BillboardEffect::init_type();
00442 Camera::init_type();
00443 ClipPlaneAttrib::init_type();
00444 ColorAttrib::init_type();
00445 ColorBlendAttrib::init_type();
00446 ColorScaleAttrib::init_type();
00447 ColorWriteAttrib::init_type();
00448 CompassEffect::init_type();
00449 CullFaceAttrib::init_type();
00450 CullBin::init_type();
00451 CullBinAttrib::init_type();
00452 CullResult::init_type();
00453 CullTraverser::init_type();
00454 CullableObject::init_type();
00455 DecalEffect::init_type();
00456 DepthOffsetAttrib::init_type();
00457 DepthTestAttrib::init_type();
00458 DepthWriteAttrib::init_type();
00459 EventStorePandaNode::init_type();
00460 FindApproxLevelEntry::init_type();
00461 Fog::init_type();
00462 FogAttrib::init_type();
00463 GeomDrawCallbackData::init_type();
00464 GeomNode::init_type();
00465 GeomTransformer::init_type();
00466 LensNode::init_type();
00467 Light::init_type();
00468 LightAttrib::init_type();
00469 LightRampAttrib::init_type();
00470 Loader::init_type();
00471 LoaderFileType::init_type();
00472 LoaderFileTypeBam::init_type();
00473 MaterialAttrib::init_type();
00474 ModelFlattenRequest::init_type();
00475 ModelLoadRequest::init_type();
00476 ModelNode::init_type();
00477 ModelRoot::init_type();
00478 NodePath::init_type();
00479 NodePathComponent::init_type();
00480 PandaNode::init_type();
00481 PandaNodePipelineReader::init_type();
00482 PlaneNode::init_type();
00483 PolylightNode::init_type();
00484 PolylightEffect::init_type();
00485 PortalNode::init_type();
00486 OccluderEffect::init_type();
00487 OccluderNode::init_type();
00488 PortalClipper::init_type();
00489 RenderAttrib::init_type();
00490 RenderEffect::init_type();
00491 RenderEffects::init_type();
00492 RenderModeAttrib::init_type();
00493 RenderState::init_type();
00494 RescaleNormalAttrib::init_type();
00495 SceneSetup::init_type();
00496 ScissorAttrib::init_type();
00497 ScissorEffect::init_type();
00498 ShadeModelAttrib::init_type();
00499 ShaderInput::init_type();
00500 ShaderAttrib::init_type();
00501 ShowBoundsEffect::init_type();
00502 StateMunger::init_type();
00503 StencilAttrib::init_type();
00504 TexMatrixAttrib::init_type();
00505 TexProjectorEffect::init_type();
00506 TextureAttrib::init_type();
00507 TexGenAttrib::init_type();
00508 TransformState::init_type();
00509 TransparencyAttrib::init_type();
00510
00511 AlphaTestAttrib::register_with_read_factory();
00512 AntialiasAttrib::register_with_read_factory();
00513 AudioVolumeAttrib::register_with_read_factory();
00514 AuxBitplaneAttrib::register_with_read_factory();
00515 BillboardEffect::register_with_read_factory();
00516 Camera::register_with_read_factory();
00517 ClipPlaneAttrib::register_with_read_factory();
00518 CompassEffect::register_with_read_factory();
00519 ColorAttrib::register_with_read_factory();
00520 ColorBlendAttrib::register_with_read_factory();
00521 ColorScaleAttrib::register_with_read_factory();
00522 ColorWriteAttrib::register_with_read_factory();
00523 CullBinAttrib::register_with_read_factory();
00524 CullFaceAttrib::register_with_read_factory();
00525 DecalEffect::register_with_read_factory();
00526 DepthOffsetAttrib::register_with_read_factory();
00527 DepthTestAttrib::register_with_read_factory();
00528 DepthWriteAttrib::register_with_read_factory();
00529 Fog::register_with_read_factory();
00530 FogAttrib::register_with_read_factory();
00531 GeomNode::register_with_read_factory();
00532 LensNode::register_with_read_factory();
00533 LightAttrib::register_with_read_factory();
00534 LightRampAttrib::register_with_read_factory();
00535 MaterialAttrib::register_with_read_factory();
00536 ModelNode::register_with_read_factory();
00537 ModelRoot::register_with_read_factory();
00538 PandaNode::register_with_read_factory();
00539 PlaneNode::register_with_read_factory();
00540 PolylightNode::register_with_read_factory();
00541 PortalNode::register_with_read_factory();
00542 OccluderEffect::register_with_read_factory();
00543 OccluderNode::register_with_read_factory();
00544 RenderEffects::register_with_read_factory();
00545 RenderModeAttrib::register_with_read_factory();
00546 RenderState::register_with_read_factory();
00547 RescaleNormalAttrib::register_with_read_factory();
00548 ScissorAttrib::register_with_read_factory();
00549 ScissorEffect::register_with_read_factory();
00550 ShadeModelAttrib::register_with_read_factory();
00551 ShaderInput::register_with_read_factory();
00552 ShaderAttrib::register_with_read_factory();
00553 Shader::register_with_read_factory();
00554 ShowBoundsEffect::register_with_read_factory();
00555 TexMatrixAttrib::register_with_read_factory();
00556 TexProjectorEffect::register_with_read_factory();
00557 TextureAttrib::register_with_read_factory();
00558 TexGenAttrib::register_with_read_factory();
00559 TransformState::register_with_read_factory();
00560 TransparencyAttrib::register_with_read_factory();
00561
00562
00563
00564
00565 TransformState::init_states();
00566 RenderState::init_states();
00567 RenderEffects::init_states();
00568
00569 LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr();
00570 reg->register_type(new LoaderFileTypeBam);
00571 }