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