diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm index 91bd0fbbb9..4f08044a85 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm @@ -53,8 +53,10 @@ CocoaGraphicsPipe(CGDirectDisplayID display) : _display(display) { _display_height = CGDisplayPixelsHigh(_display); load_display_information(); - cocoadisplay_cat.debug() - << "Creating CocoaGraphicsPipe for display ID " << _display << "\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Creating CocoaGraphicsPipe for display ID " << _display << "\n"; + } } /** diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index 357582180b..7ffdc23729 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm @@ -323,8 +323,10 @@ choose_pixel_format(const FrameBufferProperties &properties, } // For now, I'm just using the first virtual screen. - cocoadisplay_cat.debug() << - "Pixel format has " << [format numberOfVirtualScreens] << " virtual screens.\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() << + "Pixel format has " << [format numberOfVirtualScreens] << " virtual screens.\n"; + } get_properties(_fbprops, format, 0); // Don't enable sRGB unless it was explicitly requested. @@ -346,8 +348,10 @@ choose_pixel_format(const FrameBufferProperties &properties, GLint swap = 0; [_context setValues:&swap forParameter:NSOpenGLCPSwapInterval]; - cocoadisplay_cat.debug() - << "Created context " << _context << ": " << _fbprops << "\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Created context " << _context << ": " << _fbprops << "\n"; + } } /** diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 42490b43da..7b09d3424a 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -194,8 +194,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { _context_needs_update = true; [cocoagsg->_context setView:_view]; - cocoadisplay_cat.spam() - << "Switching context to view " << _view << "\n"; + if (cocoadisplay_cat.is_spam()) { + cocoadisplay_cat.spam() + << "Switching context to view " << _view << "\n"; + } } } @@ -918,8 +920,11 @@ set_properties_now(WindowProperties &properties) { frame.origin.x = x; frame.origin.y = container.size.height - y - frame.size.height; - cocoadisplay_cat.debug() - << "Setting window content origin to " << frame.origin.x << ", " << frame.origin.y << "\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Setting window content origin to " + << frame.origin.x << ", " << frame.origin.y << "\n"; + } if (_window != nil) { [_window setFrame:[_window frameRectForContentRect:frame] display:NO]; @@ -1472,16 +1477,20 @@ handle_close_request() { // and process it directly. throw_event(close_request_event); - cocoadisplay_cat.debug() - << "Window requested close. Rejecting, throwing event " - << close_request_event << " instead\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Window requested close. Rejecting, throwing event " + << close_request_event << " instead\n"; + } // Prevent the operating system from closing the window. return false; } - cocoadisplay_cat.debug() - << "Window requested close, accepting\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Window requested close, accepting\n"; + } // Let the operating system close the window normally. return true; @@ -1492,7 +1501,9 @@ handle_close_request() { */ void CocoaGraphicsWindow:: handle_close_event() { - cocoadisplay_cat.debug() << "Window is about to close\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() << "Window is about to close\n"; + } _window = nil; @@ -1707,17 +1718,17 @@ handle_mouse_button_event(int button, bool down) { if (down) { _input->button_down(MouseButton::button(button)); -#ifndef NDEBUG - cocoadisplay_cat.spam() - << "Mouse button " << button << " down\n"; -#endif + if (cocoadisplay_cat.is_spam()) { + cocoadisplay_cat.spam() + << "Mouse button " << button << " down\n"; + } } else { _input->button_up(MouseButton::button(button)); -#ifndef NDEBUG - cocoadisplay_cat.spam() - << "Mouse button " << button << " up\n"; -#endif + if (cocoadisplay_cat.is_spam()) { + cocoadisplay_cat.spam() + << "Mouse button " << button << " up\n"; + } } } @@ -1795,8 +1806,10 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) { */ void CocoaGraphicsWindow:: handle_wheel_event(double x, double y) { - cocoadisplay_cat.spam() - << "Wheel delta " << x << ", " << y << "\n"; + if (cocoadisplay_cat.is_spam()) { + cocoadisplay_cat.spam() + << "Wheel delta " << x << ", " << y << "\n"; + } if (y > 0.0) { _input->button_down(MouseButton::wheel_up()); diff --git a/panda/src/cocoadisplay/cocoaPandaView.mm b/panda/src/cocoadisplay/cocoaPandaView.mm index 6a3f48b39a..bd06a8df90 100644 --- a/panda/src/cocoadisplay/cocoaPandaView.mm +++ b/panda/src/cocoadisplay/cocoaPandaView.mm @@ -30,8 +30,10 @@ // the redrawing since we're doing things our own way. self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawNever; - cocoadisplay_cat.debug() - << "Created CocoaPandaView " << self << " for GraphicsWindow " << window << "\n"; + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "Created CocoaPandaView " << self << " for GraphicsWindow " << window << "\n"; + } _graphicsWindow = window; return self; diff --git a/panda/src/downloader/downloadDb.cxx b/panda/src/downloader/downloadDb.cxx index 0679614c8b..be12e9fa0a 100644 --- a/panda/src/downloader/downloadDb.cxx +++ b/panda/src/downloader/downloadDb.cxx @@ -58,9 +58,10 @@ back_to_front_slash(const string &str) { */ DownloadDb:: DownloadDb(Ramfile &server_file, Filename &client_file) { - if (downloader_cat.is_debug()) + if (downloader_cat.is_debug()) { downloader_cat.debug() << "DownloadDb constructor called" << endl; + } _client_db = read_db(client_file, 0); _client_db._filename = client_file; _server_db = read_db(server_file, 1); @@ -71,9 +72,10 @@ DownloadDb(Ramfile &server_file, Filename &client_file) { */ DownloadDb:: DownloadDb(Filename &server_file, Filename &client_file) { - if (downloader_cat.is_debug()) + if (downloader_cat.is_debug()) { downloader_cat.debug() << "DownloadDb constructor called" << endl; + } _client_db = read_db(client_file, 0); _client_db._filename = client_file; _server_db = read_db(server_file, 1); @@ -94,9 +96,10 @@ DownloadDb() { */ DownloadDb:: ~DownloadDb() { - if (downloader_cat.is_debug()) + if (downloader_cat.is_debug()) { downloader_cat.debug() << "DownloadDb destructor called" << endl; + } } @@ -330,8 +333,10 @@ write_db(Filename &file, Db db, bool want_server_info) { return false; } - downloader_cat.spam() - << "Writing to file: " << file << endl; + if (downloader_cat.is_spam()) { + downloader_cat.spam() + << "Writing to file: " << file << endl; + } StreamWriter sw(write_stream); @@ -594,8 +599,10 @@ parse_header(Datagram dg) { // Make sure we have a good header DatagramIterator di(dg); uint32_t magic_number = di.get_uint32(); - downloader_cat.debug() - << "Parsed magic number: " << magic_number << endl; + if (downloader_cat.is_debug()) { + downloader_cat.debug() + << "Parsed magic number: " << magic_number << endl; + } // If the magic number is equal to the bogus magic number it signifies that // the previous write was interrupted if (magic_number == _bogus_magic_number) { @@ -614,8 +621,10 @@ parse_header(Datagram dg) { } int32_t num_multifiles = di.get_int32(); - downloader_cat.debug() - << "Parsed number of multifiles: " << num_multifiles << endl; + if (downloader_cat.is_debug()) { + downloader_cat.debug() + << "Parsed number of multifiles: " << num_multifiles << endl; + } // If we got all the way here, must be done return num_multifiles; @@ -631,8 +640,10 @@ int DownloadDb::Db:: parse_record_header(Datagram dg) { DatagramIterator di(dg); int32_t record_length = di.get_int32(); - downloader_cat.spam() - << "Parsed record header length: " << record_length << endl; + if (downloader_cat.is_spam()) { + downloader_cat.spam() + << "Parsed record header length: " << record_length << endl; + } // If we got all the way here, must be done return record_length; @@ -662,10 +673,12 @@ parse_mfr(Datagram dg) { // Read the hash value mfr->_hash.read_datagram(di); - downloader_cat.debug() - << "Parsed multifile record: " << mfr->_name << " phase: " << mfr->_phase - << " size: " << mfr->_size - << " status: " << mfr->_status << " num_files: " << mfr->_num_files << endl; + if (downloader_cat.is_debug()) { + downloader_cat.debug() + << "Parsed multifile record: " << mfr->_name << " phase: " << mfr->_phase + << " size: " << mfr->_size << " status: " << mfr->_status + << " num_files: " << mfr->_num_files << endl; + } // Return the new MultifileRecord return mfr; @@ -690,8 +703,10 @@ parse_fr(Datagram dg) { // convert any old records we might read. fr->_name = back_to_front_slash(fr->_name); - downloader_cat.spam() - << "Parsed file record: " << fr->_name << endl; + if (downloader_cat.is_spam()) { + downloader_cat.spam() + << "Parsed file record: " << fr->_name << endl; + } // Return the new MultifileRecord return fr; @@ -1022,16 +1037,21 @@ int DownloadDb:: get_version(const Filename &name, const HashVal &hash) const { VersionMap::const_iterator vmi = _versions.find(name); if (vmi == _versions.end()) { - downloader_cat.debug() - << "DownloadDb::get_version() - can't find: " << name << endl; + if (downloader_cat.is_debug()) { + downloader_cat.debug() + << "DownloadDb::get_version() - can't find: " << name << endl; + } return -1; } const VectorHash &vhash = (*vmi).second; VectorHash::const_iterator i = find(vhash.begin(), vhash.end(), hash); - if (i != vhash.end()) + if (i != vhash.end()) { return (i - vhash.begin() + 1); - downloader_cat.debug() - << "DownloadDb::get_version() - can't find hash: " << hash << endl; + } + if (downloader_cat.is_debug()) { + downloader_cat.debug() + << "DownloadDb::get_version() - can't find hash: " << hash << endl; + } return -1; } @@ -1072,9 +1092,11 @@ write_version_map(StreamWriter &sw) { sw.add_int32(_versions.size()); for (vmi = _versions.begin(); vmi != _versions.end(); ++vmi) { name = (*vmi).first; - downloader_cat.spam() - << "DownloadDb::write_version_map() - writing file: " - << name << " of length: " << name.length() << endl; + if (downloader_cat.is_spam()) { + downloader_cat.spam() + << "DownloadDb::write_version_map() - writing file: " + << name << " of length: " << name.length() << endl; + } sw.add_int32(name.length()); sw.append_data(name); sw.add_int32((*vmi).second.size()); @@ -1099,17 +1121,21 @@ read_version_map(StreamReader &sr) { // Get the file name string name = sr.get_string32(); - downloader_cat.spam() - << "DownloadDb::read_version_map() - name: " << name << endl; + if (downloader_cat.is_spam()) { + downloader_cat.spam() + << "DownloadDb::read_version_map() - name: " << name << endl; + } // Get number of hash values for name int length = sr.get_int32(); if (sr.get_istream()->fail()) { return false; } - downloader_cat.spam() - << "DownloadDb::read_version_map() - number of values: " << length - << endl; + if (downloader_cat.is_spam()) { + downloader_cat.spam() + << "DownloadDb::read_version_map() - number of values: " << length + << endl; + } for (int j = 0; j < length; j++) { HashVal hash; diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index 70c9db7803..d130acd959 100644 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -844,9 +844,11 @@ create_texture(DXScreenData &scrn) { tex->set_anisotropic_degree(aniso_degree); #ifdef _DEBUG - dxgsg9_cat.spam() - << "create_texture: setting aniso degree for " << tex->get_name() - << " to: " << aniso_degree << endl; + if (dxgsg9_cat.is_spam()) { + dxgsg9_cat.spam() + << "create_texture: setting aniso degree for " << tex->get_name() + << " to: " << aniso_degree << endl; + } #endif UINT mip_level_count; diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index 07a265a97c..ef70d24879 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -280,13 +280,17 @@ open_window() { _properties.add_properties(resized_props); } - wdxdisplay9_cat.debug() << "_wcontext._window is " << _wcontext._window << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "_wcontext._window is " << _wcontext._window << "\n"; + } if (!WinGraphicsWindow::open_window()) { return false; } _wcontext._window = _hWnd; - wdxdisplay9_cat.debug() << "_wcontext._window is " << _wcontext._window << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "_wcontext._window is " << _wcontext._window << "\n"; + } // Here check if a device already exists. If so, then this open_window call // may be an extension to create multiple windows on same device In that @@ -294,14 +298,18 @@ open_window() { while (true) { if (_dxgsg->get_pipe()->get_device() == nullptr || discard_device) { - wdxdisplay9_cat.debug() << "device is null or fullscreen\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "device is null or fullscreen\n"; + } // If device exists, free it if (_dxgsg->get_pipe()->get_device()) { _dxgsg->dx_cleanup(); } - wdxdisplay9_cat.debug() << "device width " << _wcontext._display_mode.Width << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "device width " << _wcontext._display_mode.Width << "\n"; + } if (!create_screen_buffers_and_device(_wcontext, dx_force_16bpp_zbuffer)) { wdxdisplay9_cat.error() << "Unable to create window with specified parameters.\n"; close_window(); @@ -315,7 +323,9 @@ open_window() { } else { // fill in the DXScreenData from dxdevice here and change the reference // to _window. - wdxdisplay9_cat.debug() << "device is not null\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "device is not null\n"; + } dxdev = (DXGraphicsDevice9*)_dxgsg->get_pipe()->get_device(); memcpy(&_wcontext, &dxdev->_Scrn, sizeof(DXScreenData)); @@ -325,7 +335,9 @@ open_window() { _wcontext._presentation_params.BackBufferWidth = _wcontext._display_mode.Width = _properties.get_x_size(); _wcontext._presentation_params.BackBufferHeight = _wcontext._display_mode.Height = _properties.get_y_size(); - wdxdisplay9_cat.debug() << "device width " << _wcontext._presentation_params.BackBufferWidth << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "device width " << _wcontext._presentation_params.BackBufferWidth << "\n"; + } if (!_dxgsg->create_swap_chain(&_wcontext)) { discard_device = true; continue; // try again @@ -334,7 +346,9 @@ open_window() { break; } } - wdxdisplay9_cat.debug() << "swapchain is " << _wcontext._swap_chain << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "swapchain is " << _wcontext._swap_chain << "\n"; + } return true; } @@ -349,13 +363,17 @@ reset_window(bool swapchain) { if (swapchain) { if (_wcontext._swap_chain) { _dxgsg->create_swap_chain(&_wcontext); - wdxdisplay9_cat.debug() << "created swapchain " << _wcontext._swap_chain << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "created swapchain " << _wcontext._swap_chain << "\n"; + } } } else { if (_wcontext._swap_chain) { _dxgsg->release_swap_chain(&_wcontext); - wdxdisplay9_cat.debug() << "released swapchain " << _wcontext._swap_chain << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "released swapchain " << _wcontext._swap_chain << "\n"; + } } } } @@ -532,7 +550,9 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer } } - wdxdisplay9_cat.debug() << "Display Width " << dwRenderWidth << " and PresParam Width " << _wcontext._presentation_params.BackBufferWidth << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "Display Width " << dwRenderWidth << " and PresParam Width " << _wcontext._presentation_params.BackBufferWidth << "\n"; + } // BUGBUG: need to change panda to put frame buffer properties with // GraphicsWindow, not GSG!! Update: Did I fix the bug? - Josh @@ -1164,7 +1184,9 @@ reset_device_resize_window(UINT new_xsize, UINT new_ysize) { if (screen) { _wcontext._swap_chain = screen->_swap_chain; } - wdxdisplay9_cat.debug() << "swapchain is " << _wcontext._swap_chain << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() << "swapchain is " << _wcontext._swap_chain << "\n"; + } _gsg->mark_new(); init_resized_window(); return retval; @@ -1275,8 +1297,10 @@ D3DFMT_to_DepthBits(D3DFORMAT fmt) { return 15; default: - wdxdisplay9_cat.debug() - << "D3DFMT_DepthBits: unhandled D3DFMT!\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() + << "D3DFMT_DepthBits: unhandled D3DFMT!\n"; + } return 0; } } diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index c7e212c260..ea6bb0e47b 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -575,8 +575,10 @@ internal_read_header(const Filename &patch_file) { // get the MD5 of the resultant patched file _MD5_ofResult.read_stream(patch_reader); - express_cat.debug() - << "Patchfile::initiate() - valid patchfile" << endl; + if (express_cat.is_debug()) { + express_cat.debug() + << "Patchfile::initiate() - valid patchfile" << endl; + } return EU_success; } diff --git a/panda/src/grutil/geoMipTerrain.I b/panda/src/grutil/geoMipTerrain.I index 7eeeddab7a..20f0f1241a 100644 --- a/panda/src/grutil/geoMipTerrain.I +++ b/panda/src/grutil/geoMipTerrain.I @@ -237,10 +237,14 @@ is_dirty() { * the terrain will be, but more expensive to render. A value of 0 makes the * terrain the lowest quality possible, depending on blocksize. The default * value is 100. + * + * @deprecated use set_near/set_far instead */ INLINE void GeoMipTerrain:: set_factor(PN_stdfloat factor) { - grutil_cat.debug() << "Using deprecated method set_factor, use set_near and set_far instead!\n"; + if (grutil_cat.is_debug()) { + grutil_cat.debug() << "Using deprecated method set_factor, use set_near and set_far instead!\n"; + } _use_near_far = false; _factor = factor; } diff --git a/panda/src/pgraph/polylightNode.cxx b/panda/src/pgraph/polylightNode.cxx index 73242aab04..508a1c97cf 100644 --- a/panda/src/pgraph/polylightNode.cxx +++ b/panda/src/pgraph/polylightNode.cxx @@ -134,7 +134,9 @@ LColor PolylightNode::flicker() const { b = color[2]; } */ - pgraph_cat.debug() << "Color R:" << r << "; G:" << g << "; B:" << b << std::endl; + if (pgraph_cat.is_debug()) { + pgraph_cat.debug() << "Color R:" << r << "; G:" << g << "; B:" << b << std::endl; + } return LColor(r,g,b,1.0); } diff --git a/panda/src/pgraph/portalClipper.I b/panda/src/pgraph/portalClipper.I index 6dd31056e2..1e5a7c5b8f 100644 --- a/panda/src/pgraph/portalClipper.I +++ b/panda/src/pgraph/portalClipper.I @@ -140,7 +140,9 @@ get_reduced_viewport(LPoint2& min, LPoint2& max) const { */ INLINE bool PortalClipper:: is_facing_view(const LPlane &portal_plane) { - portal_cat.debug() << "portal plane check value: " << portal_plane[3] << "\n"; + if (portal_cat.is_debug()) { + portal_cat.debug() << "portal plane check value: " << portal_plane[3] << "\n"; + } return (portal_plane[3] > 0); } @@ -161,7 +163,9 @@ is_whole_portal_in_view(const LMatrix4 &cmat) { int result = _reduced_frustum->contains(gbv); - portal_cat.spam() << "1st level test if portal: " << *_reduced_frustum << " is in view " << result << std::endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << "1st level test if portal: " << *_reduced_frustum << " is in view " << result << std::endl; + } return (result != 0); } @@ -179,7 +183,9 @@ is_partial_portal_in_view() { for (int j=0; j<_num_vert; ++j) { result |= _reduced_frustum->contains(_coords[j]); } - portal_cat.spam() << "frustum: " << *_reduced_frustum << " contains(coord) result = " << result << endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << "frustum: " << *_reduced_frustum << " contains(coord) result = " << result << endl; + } return (result != 0); } @@ -193,9 +199,11 @@ INLINE PN_stdfloat PortalClipper:: get_plane_depth(PN_stdfloat x, PN_stdfloat z, LPlane *portal_plane) { PN_stdfloat y = 0.0; // Plane equation: Ax + By + Cz + D = 0 y = (Ax + Cz + D) -B - portal_cat.spam() << *portal_plane << endl; - portal_cat.spam() << portal_plane->_v.v._0 << " " << portal_plane->_v.v._1 << " " - << portal_plane->_v.v._2 << " " << portal_plane->_v.v._3 << endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << *portal_plane << endl; + portal_cat.spam() << portal_plane->_v.v._0 << " " << portal_plane->_v.v._1 << " " + << portal_plane->_v.v._2 << " " << portal_plane->_v.v._3 << endl; + } if (portal_plane->_v.v._1 != 0.0) { y = (((portal_plane->_v.v._0*x)+(portal_plane->_v.v._2*z)+portal_plane->_v.v._3) diff --git a/panda/src/pgraph/portalClipper.cxx b/panda/src/pgraph/portalClipper.cxx index d9d1af727d..22d032a728 100644 --- a/panda/src/pgraph/portalClipper.cxx +++ b/panda/src/pgraph/portalClipper.cxx @@ -210,14 +210,18 @@ prepare_portal(const NodePath &node_path) } // Get the geometry from the portal - portal_cat.spam() << *_portal_node << endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << *_portal_node << endl; + } // Get the camera transformation matrix CPT(TransformState) ctransform = node_path.get_transform(_scene_setup->get_cull_center()); // CPT(TransformState) ctransform = // node_path.get_transform(_scene_setup->get_camera_path()); LMatrix4 cmat = ctransform->get_mat(); - portal_cat.spam() << cmat << endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << cmat << endl; + } LVertex temp[4]; temp[0] = _portal_node->get_vertex(0); @@ -225,11 +229,13 @@ prepare_portal(const NodePath &node_path) temp[2] = _portal_node->get_vertex(2); temp[3] = _portal_node->get_vertex(3); - portal_cat.spam() << "before transformation to camera space" << endl; - portal_cat.spam() << temp[0] << endl; - portal_cat.spam() << temp[1] << endl; - portal_cat.spam() << temp[2] << endl; - portal_cat.spam() << temp[3] << endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << "before transformation to camera space" << endl; + portal_cat.spam() << temp[0] << endl; + portal_cat.spam() << temp[1] << endl; + portal_cat.spam() << temp[2] << endl; + portal_cat.spam() << temp[3] << endl; + } temp[0] = temp[0]*cmat; temp[1] = temp[1]*cmat; @@ -238,15 +244,19 @@ prepare_portal(const NodePath &node_path) LPlane portal_plane(temp[0], temp[1], temp[2]); if (!is_facing_view(portal_plane)) { - portal_cat.debug() << "portal failed 1st level test (isn't facing the camera)\n"; + if (portal_cat.is_debug()) { + portal_cat.debug() << "portal failed 1st level test (isn't facing the camera)\n"; + } return false; } - portal_cat.spam() << "after transformation to camera space" << endl; - portal_cat.spam() << temp[0] << endl; - portal_cat.spam() << temp[1] << endl; - portal_cat.spam() << temp[2] << endl; - portal_cat.spam() << temp[3] << endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << "after transformation to camera space" << endl; + portal_cat.spam() << temp[0] << endl; + portal_cat.spam() << temp[1] << endl; + portal_cat.spam() << temp[2] << endl; + portal_cat.spam() << temp[3] << endl; + } // check if the portal intersects with the cameras 0 point (center of // projection). In that case the portal will invert itself. portals @@ -270,7 +280,9 @@ prepare_portal(const NodePath &node_path) (temp[1][forward_axis] * forward[forward_axis] <= 0) || (temp[2][forward_axis] * forward[forward_axis] <= 0) || (temp[3][forward_axis] * forward[forward_axis] <= 0)) { - portal_cat.debug() << "portal intersects with center of projection.." << endl; + if (portal_cat.is_debug()) { + portal_cat.debug() << "portal intersects with center of projection.." << endl; + } return true; } @@ -281,11 +293,13 @@ prepare_portal(const NodePath &node_path) lens->project(temp[2], projected_coords[2]); lens->project(temp[3], projected_coords[3]); - portal_cat.spam() << "after projection to 2d" << endl; - portal_cat.spam() << projected_coords[0] << endl; - portal_cat.spam() << projected_coords[1] << endl; - portal_cat.spam() << projected_coords[2] << endl; - portal_cat.spam() << projected_coords[3] << endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << "after projection to 2d" << endl; + portal_cat.spam() << projected_coords[0] << endl; + portal_cat.spam() << projected_coords[1] << endl; + portal_cat.spam() << projected_coords[2] << endl; + portal_cat.spam() << projected_coords[3] << endl; + } // calculate axis aligned bounding box of the portal PN_stdfloat min_x, max_x, min_y, max_y; @@ -294,7 +308,9 @@ prepare_portal(const NodePath &node_path) min_y = min(min(min(projected_coords[0][1], projected_coords[1][1]), projected_coords[2][1]), projected_coords[3][1]); max_y = max(max(max(projected_coords[0][1], projected_coords[1][1]), projected_coords[2][1]), projected_coords[3][1]); - portal_cat.spam() << "min_x " << min_x << ";max_x " << max_x << ";min_y " << min_y << ";max_y " << max_y << endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << "min_x " << min_x << ";max_x " << max_x << ";min_y " << min_y << ";max_y " << max_y << endl; + } // clip the minima and maxima against the viewport min_x = max(min_x, _reduced_viewport_min[0]); @@ -302,11 +318,15 @@ prepare_portal(const NodePath &node_path) max_x = min(max_x, _reduced_viewport_max[0]); max_y = min(max_y, _reduced_viewport_max[1]); - portal_cat.spam() << "after clipping: min_x " << min_x << ";max_x " << max_x << ";min_y " << min_y << ";max_y " << max_y << endl; + if (portal_cat.is_spam()) { + portal_cat.spam() << "after clipping: min_x " << min_x << ";max_x " << max_x << ";min_y " << min_y << ";max_y " << max_y << endl; + } if ((min_x >= max_x) || (min_y >= max_y)) { + if (portal_cat.is_debug()) { portal_cat.debug() << "portal got clipped away \n"; - return false; + } + return false; } // here we know the portal is in view and we have its clipped extents @@ -325,7 +345,9 @@ prepare_portal(const NodePath &node_path) _reduced_frustum = new BoundingHexahedron(far_point[0], far_point[1], far_point[2], far_point[3], near_point[0], near_point[1], near_point[2], near_point[3]); - portal_cat.debug() << *_reduced_frustum << endl; + if (portal_cat.is_debug()) { + portal_cat.debug() << *_reduced_frustum << endl; + } // do debug rendering, if requested if (debug_portal_cull) { diff --git a/panda/src/physx/physxDebugGeomNode.cxx b/panda/src/physx/physxDebugGeomNode.cxx index 8b3bd2a1ca..a2684b0ea6 100644 --- a/panda/src/physx/physxDebugGeomNode.cxx +++ b/panda/src/physx/physxDebugGeomNode.cxx @@ -100,7 +100,9 @@ update(NxScene *scenePtr) { _prim_lines->close_primitive(); _prim_triangles->close_primitive(); - physx_cat.spam() << "Updated PhysxDebugGeomNode geometry\n"; + if (physx_cat.is_spam()) { + physx_cat.spam() << "Updated PhysxDebugGeomNode geometry\n"; + } } /** diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index 4dbcf06966..b042dcfde2 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -676,21 +676,27 @@ do_read_index(const Filename &index_pathname) { DatagramInputFile din; if (!din.open(index_pathname)) { - util_cat.debug() - << "Could not read index file: " << index_pathname << "\n"; + if (util_cat.is_debug()) { + util_cat.debug() + << "Could not read index file: " << index_pathname << "\n"; + } return nullptr; } string head; if (!din.read_header(head, _bam_header.size())) { - util_cat.debug() - << index_pathname << " is not an index file.\n"; + if (util_cat.is_debug()) { + util_cat.debug() + << index_pathname << " is not an index file.\n"; + } return nullptr; } if (head != _bam_header) { - util_cat.debug() - << index_pathname << " is not an index file.\n"; + if (util_cat.is_debug()) { + util_cat.debug() + << index_pathname << " is not an index file.\n"; + } return nullptr; } diff --git a/panda/src/rocket/rocketFileInterface.cxx b/panda/src/rocket/rocketFileInterface.cxx index 5a54e31c8f..efdab87400 100644 --- a/panda/src/rocket/rocketFileInterface.cxx +++ b/panda/src/rocket/rocketFileInterface.cxx @@ -30,7 +30,9 @@ RocketFileInterface(VirtualFileSystem *vfs) : _vfs(vfs) { */ Rocket::Core::FileHandle RocketFileInterface:: Open(const Rocket::Core::String& path) { - rocket_cat.debug() << "Opening " << path.CString() << "\n"; + if (rocket_cat.is_debug()) { + rocket_cat.debug() << "Opening " << path.CString() << "\n"; + } Filename fn = Filename::from_os_specific(path.CString()); diff --git a/panda/src/rocket/rocketRegion.cxx b/panda/src/rocket/rocketRegion.cxx index 17fdc8f55f..3ae0b1bb47 100644 --- a/panda/src/rocket/rocketRegion.cxx +++ b/panda/src/rocket/rocketRegion.cxx @@ -44,9 +44,11 @@ RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, get_pixels(pl, pr, pb, pt); Rocket::Core::Vector2i dimensions (pr - pl, pt - pb); - rocket_cat.debug() - << "Setting initial context dimensions to (" - << dimensions.x << ", " << dimensions.y << ")\n"; + if (rocket_cat.is_debug()) { + rocket_cat.debug() + << "Setting initial context dimensions to (" + << dimensions.x << ", " << dimensions.y << ")\n"; + } _context = Rocket::Core::CreateContext(context_name.c_str(), dimensions, &_interface); @@ -112,8 +114,10 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, Rocket::Core::Vector2i dimensions (pr - pl, pt - pb); if (_context->GetDimensions() != dimensions) { - rocket_cat.debug() << "Setting context dimensions to (" - << dimensions.x << ", " << dimensions.y << ")\n"; + if (rocket_cat.is_debug()) { + rocket_cat.debug() << "Setting context dimensions to (" + << dimensions.x << ", " << dimensions.y << ")\n"; + } _context->SetDimensions(dimensions); diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index c2e98beb0e..7c88cfd299 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -200,13 +200,17 @@ close_ime() { HIMC hIMC = ImmGetContext(_hWnd); if (hIMC != 0) { if (!ImmSetOpenStatus(hIMC, false)) { - windisplay_cat.debug() << "ImmSetOpenStatus failed\n"; + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "ImmSetOpenStatus failed\n"; + } } ImmReleaseContext(_hWnd, hIMC); } _ime_open = false; - windisplay_cat.debug() << "success: closed ime window\n"; + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "success: closed ime window\n"; + } return; } @@ -1663,18 +1667,30 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (!ime_hide) break; - windisplay_cat.debug() << "hwnd = " << hwnd << " and GetFocus = " << GetFocus() << endl; + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "hwnd = " << hwnd << " and GetFocus = " << GetFocus() << endl; + } _ime_hWnd = ImmGetDefaultIMEWnd(hwnd); - if (::SendMessage(_ime_hWnd, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0)) + if (::SendMessage(_ime_hWnd, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0)) { // if (::SendMessage(hwnd, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0)) - windisplay_cat.debug() << "SendMessage failed for " << _ime_hWnd << endl; - else - windisplay_cat.debug() << "SendMessage Succeeded for " << _ime_hWnd << endl; + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "SendMessage failed for " << _ime_hWnd << endl; + } + } else { + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "SendMessage succeeded for " << _ime_hWnd << endl; + } + } - windisplay_cat.debug() << "wparam is " << wparam << ", lparam is " << lparam << endl; - lparam &= ~ISC_SHOWUIALL; - if (ImmIsUIMessage(_ime_hWnd, msg, wparam, lparam)) + if (windisplay_cat.is_debug()) { windisplay_cat.debug() << "wparam is " << wparam << ", lparam is " << lparam << endl; + } + lparam &= ~ISC_SHOWUIALL; + if (ImmIsUIMessage(_ime_hWnd, msg, wparam, lparam)) { + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "wparam is " << wparam << ", lparam is " << lparam << endl; + } + } break; @@ -1693,16 +1709,18 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { CANDIDATEFORM canf; ImmGetCompositionWindow(hIMC, &comf); ImmGetCandidateWindow(hIMC, 0, &canf); - windisplay_cat.debug() << - "comf style " << comf.dwStyle << - " comf point: x" << comf.ptCurrentPos.x << ",y " << comf.ptCurrentPos.y << - " comf rect: l " << comf.rcArea.left << ",t " << comf.rcArea.top << ",r " << - comf.rcArea.right << ",b " << comf.rcArea.bottom << endl; - windisplay_cat.debug() << - "canf style " << canf.dwStyle << - " canf point: x" << canf.ptCurrentPos.x << ",y " << canf.ptCurrentPos.y << - " canf rect: l " << canf.rcArea.left << ",t " << canf.rcArea.top << ",r " << + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << + "comf style " << comf.dwStyle << + " comf point: x" << comf.ptCurrentPos.x << ",y " << comf.ptCurrentPos.y << + " comf rect: l " << comf.rcArea.left << ",t " << comf.rcArea.top << ",r " << + comf.rcArea.right << ",b " << comf.rcArea.bottom << endl; + windisplay_cat.debug() << + "canf style " << canf.dwStyle << + " canf point: x" << canf.ptCurrentPos.x << ",y " << canf.ptCurrentPos.y << + " canf rect: l " << canf.rcArea.left << ",t " << canf.rcArea.top << ",r " << canf.rcArea.right << ",b " << canf.rcArea.bottom << endl; + } comf.dwStyle = CFS_POINT; comf.ptCurrentPos.x = 2000; comf.ptCurrentPos.y = 2000; @@ -1723,11 +1741,17 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { comf.rcArea.bottom = 0; #endif - if (ImmSetCompositionWindow(hIMC, &comf)) - windisplay_cat.debug() << "set composition form: success\n"; + if (ImmSetCompositionWindow(hIMC, &comf)) { + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "set composition form: success\n"; + } + } for (int i=0; i<3; ++i) { - if (ImmSetCandidateWindow(hIMC, &canf)) - windisplay_cat.debug() << "set candidate form: success\n"; + if (ImmSetCandidateWindow(hIMC, &canf)) { + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() << "set candidate form: success\n"; + } + } canf.dwIndex++; } } diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index 099538991a..9801d6b13b 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -233,8 +233,11 @@ load_texture(size_t index) { if (tex.mHeight == 0) { // Compressed texture. - assimp_cat.debug() - << "Reading embedded compressed texture with format " << tex.achFormatHint << " and size " << tex.mWidth << "\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() + << "Reading embedded compressed texture with format " + << tex.achFormatHint << " and size " << tex.mWidth << "\n"; + } stringstream str; str.write((char*) tex.pcData, tex.mWidth); @@ -260,8 +263,10 @@ load_texture(size_t index) { } } } else { - assimp_cat.debug() - << "Reading embedded raw texture with size " << tex.mWidth << "x" << tex.mHeight << "\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() + << "Reading embedded raw texture with size " << tex.mWidth << "x" << tex.mHeight << "\n"; + } ptex->setup_2d_texture(tex.mWidth, tex.mHeight, Texture::T_unsigned_byte, Texture::F_rgba); PTA_uchar data = ptex->modify_ram_image(); @@ -447,8 +452,10 @@ create_joint(Character *character, CharacterJointBundle *bundle, PartGroup *pare t.a4, t.b4, t.c4, t.d4); PT(CharacterJoint) joint = new CharacterJoint(character, bundle, parent, node.mName.C_Str(), mat); - assimp_cat.debug() - << "Creating joint for: " << node.mName.C_Str() << "\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() + << "Creating joint for: " << node.mName.C_Str() << "\n"; + } for (size_t i = 0; i < node.mNumChildren; ++i) { if (_bonemap.find(node.mChildren[i]->mName.C_Str()) != _bonemap.end()) { @@ -473,8 +480,10 @@ create_anim_channel(const aiAnimation &anim, AnimBundle *bundle, AnimGroup *pare } if (node_anim) { - assimp_cat.debug() - << "Found channel for node: " << node.mName.C_Str() << "\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() + << "Found channel for node: " << node.mName.C_Str() << "\n"; + } // assimp_cat.debug() << "Num Position Keys " << // node_anim->mNumPositionKeys << "\n"; assimp_cat.debug() << "Num // Rotation Keys " << node_anim->mNumRotationKeys << "\n"; @@ -522,7 +531,7 @@ create_anim_channel(const aiAnimation &anim, AnimBundle *bundle, AnimGroup *pare group->set_table('j', tablej); group->set_table('k', tablek); } - else { + else if (assimp_cat.is_debug()) { assimp_cat.debug() << "No channel found for node: " << node.mName.C_Str() << "\n"; } @@ -589,8 +598,10 @@ load_mesh(size_t index) { const aiBone &bone = *mesh.mBones[i]; CharacterJoint *joint = character->find_joint(bone.mName.C_Str()); if (joint == nullptr) { - assimp_cat.debug() - << "Could not find joint for bone: " << bone.mName.C_Str() << "\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() + << "Could not find joint for bone: " << bone.mName.C_Str() << "\n"; + } continue; } @@ -632,8 +643,11 @@ load_mesh(size_t index) { aiAnimation &ai_anim = *_scene->mAnimations[i]; bool convert_anim = false; - assimp_cat.debug() - << "Checking to see if anim (" << ai_anim.mName.C_Str() << ") matches character (" << mesh.mName.C_Str() << ")\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() + << "Checking to see if anim (" << ai_anim.mName.C_Str() + << ") matches character (" << mesh.mName.C_Str() << ")\n"; + } for (size_t j = 0; j < ai_anim.mNumChannels; ++j) { if (assimp_cat.is_spam()) { assimp_cat.spam() @@ -647,8 +661,11 @@ load_mesh(size_t index) { } if (convert_anim) { - assimp_cat.debug() - << "Found animation (" << ai_anim.mName.C_Str() << ") for character (" << mesh.mName.C_Str() << ")\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() + << "Found animation (" << ai_anim.mName.C_Str() + << ") for character (" << mesh.mName.C_Str() << ")\n"; + } // Now create the animation unsigned int frames = 0; @@ -664,10 +681,12 @@ load_mesh(size_t index) { } } PN_stdfloat fps = frames / (ai_anim.mTicksPerSecond * ai_anim.mDuration); - assimp_cat.debug() - << "FPS " << fps << "\n"; - assimp_cat.debug() - << "Frames " << frames << "\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() + << "FPS " << fps << "\n"; + assimp_cat.debug() + << "Frames " << frames << "\n"; + } PT(AnimBundle) bundle = new AnimBundle(mesh.mName.C_Str(), fps, frames); PT(AnimGroup) skeleton = new AnimGroup(bundle, ""); @@ -935,8 +954,10 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) { if (prune) { // This is an empty node in a hierarchy of joints, prune it. parent->remove_child(pnode); - assimp_cat.debug() - << "Pruning node '" << name << "'\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() + << "Pruning node '" << name << "'\n"; + } return false; } else { return true; @@ -949,7 +970,9 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) { void AssimpLoader:: load_light(const aiLight &light) { string name (light.mName.data, light.mName.length); - assimp_cat.debug() << "Found light '" << name << "'\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() << "Found light '" << name << "'\n"; + } aiColor3D col; aiVector3D vec; diff --git a/pandatool/src/assimp/pandaLogger.cxx b/pandatool/src/assimp/pandaLogger.cxx index 2b92cfbc17..c9897533cf 100644 --- a/pandatool/src/assimp/pandaLogger.cxx +++ b/pandatool/src/assimp/pandaLogger.cxx @@ -35,7 +35,9 @@ set_default() { * */ void PandaLogger::OnDebug(const char *message) { - assimp_cat.debug() << message << "\n"; + if (assimp_cat.is_debug()) { + assimp_cat.debug() << message << "\n"; + } } /** diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx index 36bf6fd895..ac221344d7 100644 --- a/pandatool/src/daeegg/daeMaterials.cxx +++ b/pandatool/src/daeegg/daeMaterials.cxx @@ -73,12 +73,16 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { } // Handle the material stuff - daeegg_cat.spam() << "Trying to process material with semantic " << semantic << endl; + if (daeegg_cat.is_spam()) { + daeegg_cat.spam() << "Trying to process material with semantic " << semantic << endl; + } PT_EggMaterial egg_material = new EggMaterial(semantic); pvector egg_textures; const FCDEffect* effect = instance->GetMaterial()->GetEffect(); if (effect == nullptr) { - daeegg_cat.debug() << "Ignoring material (semantic: " << semantic << ") without assigned effect" << endl; + if (daeegg_cat.is_debug()) { + daeegg_cat.debug() << "Ignoring material (semantic: " << semantic << ") without assigned effect" << endl; + } } else { // Grab the common profile effect const FCDEffectStandard* effect_common = (FCDEffectStandard *)effect->FindProfile(FUDaeProfileType::COMMON); @@ -86,7 +90,9 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { daeegg_cat.info() << "Ignoring effect referenced by material with semantic " << semantic << " because it has no common profile" << endl; } else { - daeegg_cat.spam() << "Processing effect, material semantic is " << semantic << endl; + if (daeegg_cat.is_spam()) { + daeegg_cat.spam() << "Processing effect, material semantic is " << semantic << endl; + } // Set the material parameters egg_material->set_amb(TO_COLOR(effect_common->GetAmbientColor())); // We already process transparency using blend modes LVecBase4 diffuse = @@ -115,7 +121,9 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { // Find an tag to support some extra stuff from extensions process_extra(semantic, effect->GetExtra()); } - daeegg_cat.spam() << "Found " << egg_textures.size() << " textures in material" << endl; + if (daeegg_cat.is_spam()) { + daeegg_cat.spam() << "Found " << egg_textures.size() << " textures in material" << endl; + } _materials[semantic]->_egg_material = egg_material; } @@ -140,7 +148,9 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co texpath = Filename::from_os_specific(FROM_FSTRING(image->GetFilename())); texpath.make_canonical(); texpath.make_relative_to(docpath.get_dirname(), true); - daeegg_cat.debug() << "Found texture with path " << texpath << endl; + if (daeegg_cat.is_debug()) { + daeegg_cat.debug() << "Found texture with path " << texpath << endl; + } } else { // Never mind. texpath = Filename::from_os_specific(FROM_FSTRING(image->GetFilename())); @@ -149,7 +159,9 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co // Find a set of UV coordinates const FCDEffectParameterInt* uvset = effect_common->GetTexture(bucket, tx)->GetSet(); if (uvset != nullptr) { - daeegg_cat.debug() << "Texture has uv name '" << FROM_FSTRING(uvset->GetSemantic()) << "'\n"; + if (daeegg_cat.is_debug()) { + daeegg_cat.debug() << "Texture has uv name '" << FROM_FSTRING(uvset->GetSemantic()) << "'\n"; + } string uvset_semantic (FROM_FSTRING(uvset->GetSemantic())); // Only set the UV name if this UV set actually exists. @@ -216,7 +228,9 @@ apply_to_primitive(const string semantic, const PT(EggPrimitive) to) { if (_materials.count(semantic) > 0) { to->set_material(_materials[semantic]->_egg_material); for (pvector::iterator it = _materials[semantic]->_egg_textures.begin(); it != _materials[semantic]->_egg_textures.end(); ++it) { - daeegg_cat.spam() << "Applying texture " << (*it)->get_name() << " from material with semantic " << semantic << endl; + if (daeegg_cat.is_spam()) { + daeegg_cat.spam() << "Applying texture " << (*it)->get_name() << " from material with semantic " << semantic << endl; + } to->add_texture(*it); } to->set_bface_flag(_materials[semantic]->_double_sided); @@ -271,11 +285,15 @@ get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semanti // semantic TEXCOORD. for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) { if (_materials[semantic]->_uvsets[i]->_input_set == input_set) { - daeegg_cat.debug() << "Using uv set with non-matching input semantic " << _materials[semantic]->_uvsets[i]->_semantic << "\n"; + if (daeegg_cat.is_debug()) { + daeegg_cat.debug() << "Using uv set with non-matching input semantic " << _materials[semantic]->_uvsets[i]->_semantic << "\n"; + } return _materials[semantic]->_uvsets[i]->_semantic; } } - daeegg_cat.debug() << "No uv set binding found for input set " << input_set << "\n"; + if (daeegg_cat.is_debug()) { + daeegg_cat.debug() << "No uv set binding found for input set " << input_set << "\n"; + } } } return ""; diff --git a/pandatool/src/daeegg/daeToEggConverter.cxx b/pandatool/src/daeegg/daeToEggConverter.cxx index a923a67264..7e5aa6673e 100644 --- a/pandatool/src/daeegg/daeToEggConverter.cxx +++ b/pandatool/src/daeegg/daeToEggConverter.cxx @@ -175,7 +175,9 @@ convert_file(const Filename &filename) { if (mesh != nullptr) { PT(DaeMaterials) materials = new DaeMaterials(character->_instance); - daeegg_cat.spam() << "Processing mesh for controller\n"; + if (daeegg_cat.is_spam()) { + daeegg_cat.spam() << "Processing mesh for controller\n"; + } process_mesh(character->_node_group, mesh, materials, character); } } @@ -373,7 +375,9 @@ void DAEToEggConverter:: process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) { nassertv(node != nullptr); string node_id = FROM_FSTRING(node->GetDaeId()); - daeegg_cat.spam() << "Processing node with ID '" << node_id << "'" << endl; + if (daeegg_cat.is_spam()) { + daeegg_cat.spam() << "Processing node with ID '" << node_id << "'" << endl; + } // Create an egg group for this node PT(EggGroup) node_group = new EggGroup(FROM_FSTRING(node->GetDaeId())); @@ -470,7 +474,9 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, DaeMaterials *materials, DaeCharacter *character) { nassertv(mesh != nullptr); - daeegg_cat.debug() << "Processing mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << endl; + if (daeegg_cat.is_debug()) { + daeegg_cat.debug() << "Processing mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << endl; + } // Create the egg stuff to hold this mesh PT(EggGroup) mesh_group = new EggGroup(FROM_FSTRING(mesh->GetDaeId())); @@ -480,17 +486,23 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, // First retrieve the vertex source if (mesh->GetSourceCount() == 0) { - daeegg_cat.debug() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has no sources" << endl; + if (daeegg_cat.is_debug()) { + daeegg_cat.debug() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has no sources" << endl; + } return; } const FCDGeometrySource* vsource = mesh->FindSourceByType(FUDaeGeometryInput::POSITION); if (vsource == nullptr) { - daeegg_cat.debug() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has no source for POSITION data" << endl; + if (daeegg_cat.is_debug()) { + daeegg_cat.debug() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has no source for POSITION data" << endl; + } return; } // Loop through the polygon groups and add them - daeegg_cat.spam() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has " << mesh->GetPolygonsCount() << " polygon groups" << endl; + if (daeegg_cat.is_spam()) { + daeegg_cat.spam() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has " << mesh->GetPolygonsCount() << " polygon groups" << endl; + } if (mesh->GetPolygonsCount() == 0) return; // This is an array of pointers, I know. But since they are refcounted, I @@ -734,7 +746,9 @@ process_controller(EggGroup *parent, const FCDControllerInstance *instance) { const FCDGeometryMesh *mesh = controller->GetBaseGeometry()->GetMesh(); if (mesh != nullptr) { PT(DaeMaterials) materials = new DaeMaterials(instance); - daeegg_cat.spam() << "Processing mesh for controller\n"; + if (daeegg_cat.is_spam()) { + daeegg_cat.spam() << "Processing mesh for controller\n"; + } process_mesh(parent, mesh, materials); } } else { diff --git a/pandatool/src/maya/mayaShaders.cxx b/pandatool/src/maya/mayaShaders.cxx index dca3712366..3809574bcb 100644 --- a/pandatool/src/maya/mayaShaders.cxx +++ b/pandatool/src/maya/mayaShaders.cxx @@ -87,8 +87,10 @@ find_shader_for_node(MObject node, bool legacy_shader) { } // Well, we didn't find a ShadingEngine after all. Huh. - maya_cat.debug() - << node_fn.name().asChar() << " : no shading engine found.\n"; + if (maya_cat.is_debug()) { + maya_cat.debug() + << node_fn.name().asChar() << " : no shading engine found.\n"; + } return nullptr; }