cleanup: fix a host of unprotected debug/spam messages

This commit is contained in:
rdb 2019-08-23 15:10:20 +02:00
parent 1ec7c5d20e
commit 5e7e64179b
22 changed files with 392 additions and 184 deletions

View File

@ -53,8 +53,10 @@ CocoaGraphicsPipe(CGDirectDisplayID display) : _display(display) {
_display_height = CGDisplayPixelsHigh(_display); _display_height = CGDisplayPixelsHigh(_display);
load_display_information(); load_display_information();
cocoadisplay_cat.debug() if (cocoadisplay_cat.is_debug()) {
<< "Creating CocoaGraphicsPipe for display ID " << _display << "\n"; cocoadisplay_cat.debug()
<< "Creating CocoaGraphicsPipe for display ID " << _display << "\n";
}
} }
/** /**

View File

@ -323,8 +323,10 @@ choose_pixel_format(const FrameBufferProperties &properties,
} }
// For now, I'm just using the first virtual screen. // For now, I'm just using the first virtual screen.
cocoadisplay_cat.debug() << if (cocoadisplay_cat.is_debug()) {
"Pixel format has " << [format numberOfVirtualScreens] << " virtual screens.\n"; cocoadisplay_cat.debug() <<
"Pixel format has " << [format numberOfVirtualScreens] << " virtual screens.\n";
}
get_properties(_fbprops, format, 0); get_properties(_fbprops, format, 0);
// Don't enable sRGB unless it was explicitly requested. // Don't enable sRGB unless it was explicitly requested.
@ -346,8 +348,10 @@ choose_pixel_format(const FrameBufferProperties &properties,
GLint swap = 0; GLint swap = 0;
[_context setValues:&swap forParameter:NSOpenGLCPSwapInterval]; [_context setValues:&swap forParameter:NSOpenGLCPSwapInterval];
cocoadisplay_cat.debug() if (cocoadisplay_cat.is_debug()) {
<< "Created context " << _context << ": " << _fbprops << "\n"; cocoadisplay_cat.debug()
<< "Created context " << _context << ": " << _fbprops << "\n";
}
} }
/** /**

View File

@ -194,8 +194,10 @@ begin_frame(FrameMode mode, Thread *current_thread) {
_context_needs_update = true; _context_needs_update = true;
[cocoagsg->_context setView:_view]; [cocoagsg->_context setView:_view];
cocoadisplay_cat.spam() if (cocoadisplay_cat.is_spam()) {
<< "Switching context to view " << _view << "\n"; cocoadisplay_cat.spam()
<< "Switching context to view " << _view << "\n";
}
} }
} }
@ -918,8 +920,11 @@ set_properties_now(WindowProperties &properties) {
frame.origin.x = x; frame.origin.x = x;
frame.origin.y = container.size.height - y - frame.size.height; frame.origin.y = container.size.height - y - frame.size.height;
cocoadisplay_cat.debug() if (cocoadisplay_cat.is_debug()) {
<< "Setting window content origin to " << frame.origin.x << ", " << frame.origin.y << "\n"; cocoadisplay_cat.debug()
<< "Setting window content origin to "
<< frame.origin.x << ", " << frame.origin.y << "\n";
}
if (_window != nil) { if (_window != nil) {
[_window setFrame:[_window frameRectForContentRect:frame] display:NO]; [_window setFrame:[_window frameRectForContentRect:frame] display:NO];
@ -1472,16 +1477,20 @@ handle_close_request() {
// and process it directly. // and process it directly.
throw_event(close_request_event); throw_event(close_request_event);
cocoadisplay_cat.debug() if (cocoadisplay_cat.is_debug()) {
<< "Window requested close. Rejecting, throwing event " cocoadisplay_cat.debug()
<< close_request_event << " instead\n"; << "Window requested close. Rejecting, throwing event "
<< close_request_event << " instead\n";
}
// Prevent the operating system from closing the window. // Prevent the operating system from closing the window.
return false; return false;
} }
cocoadisplay_cat.debug() if (cocoadisplay_cat.is_debug()) {
<< "Window requested close, accepting\n"; cocoadisplay_cat.debug()
<< "Window requested close, accepting\n";
}
// Let the operating system close the window normally. // Let the operating system close the window normally.
return true; return true;
@ -1492,7 +1501,9 @@ handle_close_request() {
*/ */
void CocoaGraphicsWindow:: void CocoaGraphicsWindow::
handle_close_event() { 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; _window = nil;
@ -1707,17 +1718,17 @@ handle_mouse_button_event(int button, bool down) {
if (down) { if (down) {
_input->button_down(MouseButton::button(button)); _input->button_down(MouseButton::button(button));
#ifndef NDEBUG if (cocoadisplay_cat.is_spam()) {
cocoadisplay_cat.spam() cocoadisplay_cat.spam()
<< "Mouse button " << button << " down\n"; << "Mouse button " << button << " down\n";
#endif }
} else { } else {
_input->button_up(MouseButton::button(button)); _input->button_up(MouseButton::button(button));
#ifndef NDEBUG if (cocoadisplay_cat.is_spam()) {
cocoadisplay_cat.spam() cocoadisplay_cat.spam()
<< "Mouse button " << button << " up\n"; << "Mouse button " << button << " up\n";
#endif }
} }
} }
@ -1795,8 +1806,10 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) {
*/ */
void CocoaGraphicsWindow:: void CocoaGraphicsWindow::
handle_wheel_event(double x, double y) { handle_wheel_event(double x, double y) {
cocoadisplay_cat.spam() if (cocoadisplay_cat.is_spam()) {
<< "Wheel delta " << x << ", " << y << "\n"; cocoadisplay_cat.spam()
<< "Wheel delta " << x << ", " << y << "\n";
}
if (y > 0.0) { if (y > 0.0) {
_input->button_down(MouseButton::wheel_up()); _input->button_down(MouseButton::wheel_up());

View File

@ -30,8 +30,10 @@
// the redrawing since we're doing things our own way. // the redrawing since we're doing things our own way.
self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawNever; self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawNever;
cocoadisplay_cat.debug() if (cocoadisplay_cat.is_debug()) {
<< "Created CocoaPandaView " << self << " for GraphicsWindow " << window << "\n"; cocoadisplay_cat.debug()
<< "Created CocoaPandaView " << self << " for GraphicsWindow " << window << "\n";
}
_graphicsWindow = window; _graphicsWindow = window;
return self; return self;

View File

@ -58,9 +58,10 @@ back_to_front_slash(const string &str) {
*/ */
DownloadDb:: DownloadDb::
DownloadDb(Ramfile &server_file, Filename &client_file) { DownloadDb(Ramfile &server_file, Filename &client_file) {
if (downloader_cat.is_debug()) if (downloader_cat.is_debug()) {
downloader_cat.debug() downloader_cat.debug()
<< "DownloadDb constructor called" << endl; << "DownloadDb constructor called" << endl;
}
_client_db = read_db(client_file, 0); _client_db = read_db(client_file, 0);
_client_db._filename = client_file; _client_db._filename = client_file;
_server_db = read_db(server_file, 1); _server_db = read_db(server_file, 1);
@ -71,9 +72,10 @@ DownloadDb(Ramfile &server_file, Filename &client_file) {
*/ */
DownloadDb:: DownloadDb::
DownloadDb(Filename &server_file, Filename &client_file) { DownloadDb(Filename &server_file, Filename &client_file) {
if (downloader_cat.is_debug()) if (downloader_cat.is_debug()) {
downloader_cat.debug() downloader_cat.debug()
<< "DownloadDb constructor called" << endl; << "DownloadDb constructor called" << endl;
}
_client_db = read_db(client_file, 0); _client_db = read_db(client_file, 0);
_client_db._filename = client_file; _client_db._filename = client_file;
_server_db = read_db(server_file, 1); _server_db = read_db(server_file, 1);
@ -94,9 +96,10 @@ DownloadDb() {
*/ */
DownloadDb:: DownloadDb::
~DownloadDb() { ~DownloadDb() {
if (downloader_cat.is_debug()) if (downloader_cat.is_debug()) {
downloader_cat.debug() downloader_cat.debug()
<< "DownloadDb destructor called" << endl; << "DownloadDb destructor called" << endl;
}
} }
@ -330,8 +333,10 @@ write_db(Filename &file, Db db, bool want_server_info) {
return false; return false;
} }
downloader_cat.spam() if (downloader_cat.is_spam()) {
<< "Writing to file: " << file << endl; downloader_cat.spam()
<< "Writing to file: " << file << endl;
}
StreamWriter sw(write_stream); StreamWriter sw(write_stream);
@ -594,8 +599,10 @@ parse_header(Datagram dg) {
// Make sure we have a good header // Make sure we have a good header
DatagramIterator di(dg); DatagramIterator di(dg);
uint32_t magic_number = di.get_uint32(); uint32_t magic_number = di.get_uint32();
downloader_cat.debug() if (downloader_cat.is_debug()) {
<< "Parsed magic number: " << magic_number << endl; downloader_cat.debug()
<< "Parsed magic number: " << magic_number << endl;
}
// If the magic number is equal to the bogus magic number it signifies that // If the magic number is equal to the bogus magic number it signifies that
// the previous write was interrupted // the previous write was interrupted
if (magic_number == _bogus_magic_number) { if (magic_number == _bogus_magic_number) {
@ -614,8 +621,10 @@ parse_header(Datagram dg) {
} }
int32_t num_multifiles = di.get_int32(); int32_t num_multifiles = di.get_int32();
downloader_cat.debug() if (downloader_cat.is_debug()) {
<< "Parsed number of multifiles: " << num_multifiles << endl; downloader_cat.debug()
<< "Parsed number of multifiles: " << num_multifiles << endl;
}
// If we got all the way here, must be done // If we got all the way here, must be done
return num_multifiles; return num_multifiles;
@ -631,8 +640,10 @@ int DownloadDb::Db::
parse_record_header(Datagram dg) { parse_record_header(Datagram dg) {
DatagramIterator di(dg); DatagramIterator di(dg);
int32_t record_length = di.get_int32(); int32_t record_length = di.get_int32();
downloader_cat.spam() if (downloader_cat.is_spam()) {
<< "Parsed record header length: " << record_length << endl; downloader_cat.spam()
<< "Parsed record header length: " << record_length << endl;
}
// If we got all the way here, must be done // If we got all the way here, must be done
return record_length; return record_length;
@ -662,10 +673,12 @@ parse_mfr(Datagram dg) {
// Read the hash value // Read the hash value
mfr->_hash.read_datagram(di); mfr->_hash.read_datagram(di);
downloader_cat.debug() if (downloader_cat.is_debug()) {
<< "Parsed multifile record: " << mfr->_name << " phase: " << mfr->_phase downloader_cat.debug()
<< " size: " << mfr->_size << "Parsed multifile record: " << mfr->_name << " phase: " << mfr->_phase
<< " status: " << mfr->_status << " num_files: " << mfr->_num_files << endl; << " size: " << mfr->_size << " status: " << mfr->_status
<< " num_files: " << mfr->_num_files << endl;
}
// Return the new MultifileRecord // Return the new MultifileRecord
return mfr; return mfr;
@ -690,8 +703,10 @@ parse_fr(Datagram dg) {
// convert any old records we might read. // convert any old records we might read.
fr->_name = back_to_front_slash(fr->_name); fr->_name = back_to_front_slash(fr->_name);
downloader_cat.spam() if (downloader_cat.is_spam()) {
<< "Parsed file record: " << fr->_name << endl; downloader_cat.spam()
<< "Parsed file record: " << fr->_name << endl;
}
// Return the new MultifileRecord // Return the new MultifileRecord
return fr; return fr;
@ -1022,16 +1037,21 @@ int DownloadDb::
get_version(const Filename &name, const HashVal &hash) const { get_version(const Filename &name, const HashVal &hash) const {
VersionMap::const_iterator vmi = _versions.find(name); VersionMap::const_iterator vmi = _versions.find(name);
if (vmi == _versions.end()) { if (vmi == _versions.end()) {
downloader_cat.debug() if (downloader_cat.is_debug()) {
<< "DownloadDb::get_version() - can't find: " << name << endl; downloader_cat.debug()
<< "DownloadDb::get_version() - can't find: " << name << endl;
}
return -1; return -1;
} }
const VectorHash &vhash = (*vmi).second; const VectorHash &vhash = (*vmi).second;
VectorHash::const_iterator i = find(vhash.begin(), vhash.end(), hash); VectorHash::const_iterator i = find(vhash.begin(), vhash.end(), hash);
if (i != vhash.end()) if (i != vhash.end()) {
return (i - vhash.begin() + 1); 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; return -1;
} }
@ -1072,9 +1092,11 @@ write_version_map(StreamWriter &sw) {
sw.add_int32(_versions.size()); sw.add_int32(_versions.size());
for (vmi = _versions.begin(); vmi != _versions.end(); ++vmi) { for (vmi = _versions.begin(); vmi != _versions.end(); ++vmi) {
name = (*vmi).first; name = (*vmi).first;
downloader_cat.spam() if (downloader_cat.is_spam()) {
<< "DownloadDb::write_version_map() - writing file: " downloader_cat.spam()
<< name << " of length: " << name.length() << endl; << "DownloadDb::write_version_map() - writing file: "
<< name << " of length: " << name.length() << endl;
}
sw.add_int32(name.length()); sw.add_int32(name.length());
sw.append_data(name); sw.append_data(name);
sw.add_int32((*vmi).second.size()); sw.add_int32((*vmi).second.size());
@ -1099,17 +1121,21 @@ read_version_map(StreamReader &sr) {
// Get the file name // Get the file name
string name = sr.get_string32(); string name = sr.get_string32();
downloader_cat.spam() if (downloader_cat.is_spam()) {
<< "DownloadDb::read_version_map() - name: " << name << endl; downloader_cat.spam()
<< "DownloadDb::read_version_map() - name: " << name << endl;
}
// Get number of hash values for name // Get number of hash values for name
int length = sr.get_int32(); int length = sr.get_int32();
if (sr.get_istream()->fail()) { if (sr.get_istream()->fail()) {
return false; return false;
} }
downloader_cat.spam() if (downloader_cat.is_spam()) {
<< "DownloadDb::read_version_map() - number of values: " << length downloader_cat.spam()
<< endl; << "DownloadDb::read_version_map() - number of values: " << length
<< endl;
}
for (int j = 0; j < length; j++) { for (int j = 0; j < length; j++) {
HashVal hash; HashVal hash;

View File

@ -844,9 +844,11 @@ create_texture(DXScreenData &scrn) {
tex->set_anisotropic_degree(aniso_degree); tex->set_anisotropic_degree(aniso_degree);
#ifdef _DEBUG #ifdef _DEBUG
dxgsg9_cat.spam() if (dxgsg9_cat.is_spam()) {
<< "create_texture: setting aniso degree for " << tex->get_name() dxgsg9_cat.spam()
<< " to: " << aniso_degree << endl; << "create_texture: setting aniso degree for " << tex->get_name()
<< " to: " << aniso_degree << endl;
}
#endif #endif
UINT mip_level_count; UINT mip_level_count;

View File

@ -280,13 +280,17 @@ open_window() {
_properties.add_properties(resized_props); _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()) { if (!WinGraphicsWindow::open_window()) {
return false; return false;
} }
_wcontext._window = _hWnd; _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 // 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 // may be an extension to create multiple windows on same device In that
@ -294,14 +298,18 @@ open_window() {
while (true) { while (true) {
if (_dxgsg->get_pipe()->get_device() == nullptr || discard_device) { 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 device exists, free it
if (_dxgsg->get_pipe()->get_device()) { if (_dxgsg->get_pipe()->get_device()) {
_dxgsg->dx_cleanup(); _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)) { if (!create_screen_buffers_and_device(_wcontext, dx_force_16bpp_zbuffer)) {
wdxdisplay9_cat.error() << "Unable to create window with specified parameters.\n"; wdxdisplay9_cat.error() << "Unable to create window with specified parameters.\n";
close_window(); close_window();
@ -315,7 +323,9 @@ open_window() {
} else { } else {
// fill in the DXScreenData from dxdevice here and change the reference // fill in the DXScreenData from dxdevice here and change the reference
// to _window. // 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(); dxdev = (DXGraphicsDevice9*)_dxgsg->get_pipe()->get_device();
memcpy(&_wcontext, &dxdev->_Scrn, sizeof(DXScreenData)); 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.BackBufferWidth = _wcontext._display_mode.Width = _properties.get_x_size();
_wcontext._presentation_params.BackBufferHeight = _wcontext._display_mode.Height = _properties.get_y_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)) { if (!_dxgsg->create_swap_chain(&_wcontext)) {
discard_device = true; discard_device = true;
continue; // try again continue; // try again
@ -334,7 +346,9 @@ open_window() {
break; 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; return true;
} }
@ -349,13 +363,17 @@ reset_window(bool swapchain) {
if (swapchain) { if (swapchain) {
if (_wcontext._swap_chain) { if (_wcontext._swap_chain) {
_dxgsg->create_swap_chain(&_wcontext); _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 { else {
if (_wcontext._swap_chain) { if (_wcontext._swap_chain) {
_dxgsg->release_swap_chain(&_wcontext); _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 // BUGBUG: need to change panda to put frame buffer properties with
// GraphicsWindow, not GSG!! Update: Did I fix the bug? - Josh // 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) { if (screen) {
_wcontext._swap_chain = screen->_swap_chain; _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(); _gsg->mark_new();
init_resized_window(); init_resized_window();
return retval; return retval;
@ -1275,8 +1297,10 @@ D3DFMT_to_DepthBits(D3DFORMAT fmt) {
return 15; return 15;
default: default:
wdxdisplay9_cat.debug() if (wdxdisplay9_cat.is_debug()) {
<< "D3DFMT_DepthBits: unhandled D3DFMT!\n"; wdxdisplay9_cat.debug()
<< "D3DFMT_DepthBits: unhandled D3DFMT!\n";
}
return 0; return 0;
} }
} }

View File

@ -575,8 +575,10 @@ internal_read_header(const Filename &patch_file) {
// get the MD5 of the resultant patched file // get the MD5 of the resultant patched file
_MD5_ofResult.read_stream(patch_reader); _MD5_ofResult.read_stream(patch_reader);
express_cat.debug() if (express_cat.is_debug()) {
<< "Patchfile::initiate() - valid patchfile" << endl; express_cat.debug()
<< "Patchfile::initiate() - valid patchfile" << endl;
}
return EU_success; return EU_success;
} }

View File

@ -237,10 +237,14 @@ is_dirty() {
* the terrain will be, but more expensive to render. A value of 0 makes the * 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 * terrain the lowest quality possible, depending on blocksize. The default
* value is 100. * value is 100.
*
* @deprecated use set_near/set_far instead
*/ */
INLINE void GeoMipTerrain:: INLINE void GeoMipTerrain::
set_factor(PN_stdfloat factor) { 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; _use_near_far = false;
_factor = factor; _factor = factor;
} }

View File

@ -134,7 +134,9 @@ LColor PolylightNode::flicker() const {
b = color[2]; 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); return LColor(r,g,b,1.0);
} }

View File

@ -140,7 +140,9 @@ get_reduced_viewport(LPoint2& min, LPoint2& max) const {
*/ */
INLINE bool PortalClipper:: INLINE bool PortalClipper::
is_facing_view(const LPlane &portal_plane) { 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); return (portal_plane[3] > 0);
} }
@ -161,7 +163,9 @@ is_whole_portal_in_view(const LMatrix4 &cmat) {
int result = _reduced_frustum->contains(gbv); 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); return (result != 0);
} }
@ -179,7 +183,9 @@ is_partial_portal_in_view() {
for (int j=0; j<_num_vert; ++j) { for (int j=0; j<_num_vert; ++j) {
result |= _reduced_frustum->contains(_coords[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); return (result != 0);
} }
@ -193,9 +199,11 @@ INLINE PN_stdfloat PortalClipper::
get_plane_depth(PN_stdfloat x, PN_stdfloat z, LPlane *portal_plane) { get_plane_depth(PN_stdfloat x, PN_stdfloat z, LPlane *portal_plane) {
PN_stdfloat y = 0.0; PN_stdfloat y = 0.0;
// Plane equation: Ax + By + Cz + D = 0 y = (Ax + Cz + D) -B // Plane equation: Ax + By + Cz + D = 0 y = (Ax + Cz + D) -B
portal_cat.spam() << *portal_plane << endl; if (portal_cat.is_spam()) {
portal_cat.spam() << portal_plane->_v.v._0 << " " << portal_plane->_v.v._1 << " " portal_cat.spam() << *portal_plane << endl;
<< portal_plane->_v.v._2 << " " << portal_plane->_v.v._3 << 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) { 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) y = (((portal_plane->_v.v._0*x)+(portal_plane->_v.v._2*z)+portal_plane->_v.v._3)

View File

@ -210,14 +210,18 @@ prepare_portal(const NodePath &node_path)
} }
// Get the geometry from the portal // 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 // 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_cull_center());
// CPT(TransformState) ctransform = // CPT(TransformState) ctransform =
// node_path.get_transform(_scene_setup->get_camera_path()); // node_path.get_transform(_scene_setup->get_camera_path());
LMatrix4 cmat = ctransform->get_mat(); LMatrix4 cmat = ctransform->get_mat();
portal_cat.spam() << cmat << endl; if (portal_cat.is_spam()) {
portal_cat.spam() << cmat << endl;
}
LVertex temp[4]; LVertex temp[4];
temp[0] = _portal_node->get_vertex(0); 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[2] = _portal_node->get_vertex(2);
temp[3] = _portal_node->get_vertex(3); temp[3] = _portal_node->get_vertex(3);
portal_cat.spam() << "before transformation to camera space" << endl; if (portal_cat.is_spam()) {
portal_cat.spam() << temp[0] << endl; portal_cat.spam() << "before transformation to camera space" << endl;
portal_cat.spam() << temp[1] << endl; portal_cat.spam() << temp[0] << endl;
portal_cat.spam() << temp[2] << endl; portal_cat.spam() << temp[1] << endl;
portal_cat.spam() << temp[3] << endl; portal_cat.spam() << temp[2] << endl;
portal_cat.spam() << temp[3] << endl;
}
temp[0] = temp[0]*cmat; temp[0] = temp[0]*cmat;
temp[1] = temp[1]*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]); LPlane portal_plane(temp[0], temp[1], temp[2]);
if (!is_facing_view(portal_plane)) { 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; return false;
} }
portal_cat.spam() << "after transformation to camera space" << endl; if (portal_cat.is_spam()) {
portal_cat.spam() << temp[0] << endl; portal_cat.spam() << "after transformation to camera space" << endl;
portal_cat.spam() << temp[1] << endl; portal_cat.spam() << temp[0] << endl;
portal_cat.spam() << temp[2] << endl; portal_cat.spam() << temp[1] << endl;
portal_cat.spam() << temp[3] << 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 // check if the portal intersects with the cameras 0 point (center of
// projection). In that case the portal will invert itself. portals // 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[1][forward_axis] * forward[forward_axis] <= 0) ||
(temp[2][forward_axis] * forward[forward_axis] <= 0) || (temp[2][forward_axis] * forward[forward_axis] <= 0) ||
(temp[3][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; return true;
} }
@ -281,11 +293,13 @@ prepare_portal(const NodePath &node_path)
lens->project(temp[2], projected_coords[2]); lens->project(temp[2], projected_coords[2]);
lens->project(temp[3], projected_coords[3]); lens->project(temp[3], projected_coords[3]);
portal_cat.spam() << "after projection to 2d" << endl; if (portal_cat.is_spam()) {
portal_cat.spam() << projected_coords[0] << endl; portal_cat.spam() << "after projection to 2d" << endl;
portal_cat.spam() << projected_coords[1] << endl; portal_cat.spam() << projected_coords[0] << endl;
portal_cat.spam() << projected_coords[2] << endl; portal_cat.spam() << projected_coords[1] << endl;
portal_cat.spam() << projected_coords[3] << endl; portal_cat.spam() << projected_coords[2] << endl;
portal_cat.spam() << projected_coords[3] << endl;
}
// calculate axis aligned bounding box of the portal // calculate axis aligned bounding box of the portal
PN_stdfloat min_x, max_x, min_y, max_y; 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]); 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]); 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 // clip the minima and maxima against the viewport
min_x = max(min_x, _reduced_viewport_min[0]); 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_x = min(max_x, _reduced_viewport_max[0]);
max_y = min(max_y, _reduced_viewport_max[1]); 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 ((min_x >= max_x) || (min_y >= max_y)) {
if (portal_cat.is_debug()) {
portal_cat.debug() << "portal got clipped away \n"; 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 // 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], _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]); 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 // do debug rendering, if requested
if (debug_portal_cull) { if (debug_portal_cull) {

View File

@ -100,7 +100,9 @@ update(NxScene *scenePtr) {
_prim_lines->close_primitive(); _prim_lines->close_primitive();
_prim_triangles->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";
}
} }
/** /**

View File

@ -676,21 +676,27 @@ do_read_index(const Filename &index_pathname) {
DatagramInputFile din; DatagramInputFile din;
if (!din.open(index_pathname)) { if (!din.open(index_pathname)) {
util_cat.debug() if (util_cat.is_debug()) {
<< "Could not read index file: " << index_pathname << "\n"; util_cat.debug()
<< "Could not read index file: " << index_pathname << "\n";
}
return nullptr; return nullptr;
} }
string head; string head;
if (!din.read_header(head, _bam_header.size())) { if (!din.read_header(head, _bam_header.size())) {
util_cat.debug() if (util_cat.is_debug()) {
<< index_pathname << " is not an index file.\n"; util_cat.debug()
<< index_pathname << " is not an index file.\n";
}
return nullptr; return nullptr;
} }
if (head != _bam_header) { if (head != _bam_header) {
util_cat.debug() if (util_cat.is_debug()) {
<< index_pathname << " is not an index file.\n"; util_cat.debug()
<< index_pathname << " is not an index file.\n";
}
return nullptr; return nullptr;
} }

View File

@ -30,7 +30,9 @@ RocketFileInterface(VirtualFileSystem *vfs) : _vfs(vfs) {
*/ */
Rocket::Core::FileHandle RocketFileInterface:: Rocket::Core::FileHandle RocketFileInterface::
Open(const Rocket::Core::String& path) { 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()); Filename fn = Filename::from_os_specific(path.CString());

View File

@ -44,9 +44,11 @@ RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions,
get_pixels(pl, pr, pb, pt); get_pixels(pl, pr, pb, pt);
Rocket::Core::Vector2i dimensions (pr - pl, pt - pb); Rocket::Core::Vector2i dimensions (pr - pl, pt - pb);
rocket_cat.debug() if (rocket_cat.is_debug()) {
<< "Setting initial context dimensions to (" rocket_cat.debug()
<< dimensions.x << ", " << dimensions.y << ")\n"; << "Setting initial context dimensions to ("
<< dimensions.x << ", " << dimensions.y << ")\n";
}
_context = Rocket::Core::CreateContext(context_name.c_str(), _context = Rocket::Core::CreateContext(context_name.c_str(),
dimensions, &_interface); dimensions, &_interface);
@ -112,8 +114,10 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
Rocket::Core::Vector2i dimensions (pr - pl, pt - pb); Rocket::Core::Vector2i dimensions (pr - pl, pt - pb);
if (_context->GetDimensions() != dimensions) { if (_context->GetDimensions() != dimensions) {
rocket_cat.debug() << "Setting context dimensions to (" if (rocket_cat.is_debug()) {
<< dimensions.x << ", " << dimensions.y << ")\n"; rocket_cat.debug() << "Setting context dimensions to ("
<< dimensions.x << ", " << dimensions.y << ")\n";
}
_context->SetDimensions(dimensions); _context->SetDimensions(dimensions);

View File

@ -200,13 +200,17 @@ close_ime() {
HIMC hIMC = ImmGetContext(_hWnd); HIMC hIMC = ImmGetContext(_hWnd);
if (hIMC != 0) { if (hIMC != 0) {
if (!ImmSetOpenStatus(hIMC, false)) { if (!ImmSetOpenStatus(hIMC, false)) {
windisplay_cat.debug() << "ImmSetOpenStatus failed\n"; if (windisplay_cat.is_debug()) {
windisplay_cat.debug() << "ImmSetOpenStatus failed\n";
}
} }
ImmReleaseContext(_hWnd, hIMC); ImmReleaseContext(_hWnd, hIMC);
} }
_ime_open = false; _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; return;
} }
@ -1663,18 +1667,30 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
if (!ime_hide) if (!ime_hide)
break; 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); _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)) // if (::SendMessage(hwnd, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0))
windisplay_cat.debug() << "SendMessage failed for " << _ime_hWnd << endl; if (windisplay_cat.is_debug()) {
else windisplay_cat.debug() << "SendMessage failed for " << _ime_hWnd << endl;
windisplay_cat.debug() << "SendMessage Succeeded 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; if (windisplay_cat.is_debug()) {
lparam &= ~ISC_SHOWUIALL;
if (ImmIsUIMessage(_ime_hWnd, msg, wparam, lparam))
windisplay_cat.debug() << "wparam is " << wparam << ", lparam is " << lparam << 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;
}
}
break; break;
@ -1693,16 +1709,18 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
CANDIDATEFORM canf; CANDIDATEFORM canf;
ImmGetCompositionWindow(hIMC, &comf); ImmGetCompositionWindow(hIMC, &comf);
ImmGetCandidateWindow(hIMC, 0, &canf); ImmGetCandidateWindow(hIMC, 0, &canf);
windisplay_cat.debug() << if (windisplay_cat.is_debug()) {
"comf style " << comf.dwStyle << windisplay_cat.debug() <<
" comf point: x" << comf.ptCurrentPos.x << ",y " << comf.ptCurrentPos.y << "comf style " << comf.dwStyle <<
" comf rect: l " << comf.rcArea.left << ",t " << comf.rcArea.top << ",r " << " comf point: x" << comf.ptCurrentPos.x << ",y " << comf.ptCurrentPos.y <<
comf.rcArea.right << ",b " << comf.rcArea.bottom << endl; " comf rect: l " << comf.rcArea.left << ",t " << comf.rcArea.top << ",r " <<
windisplay_cat.debug() << comf.rcArea.right << ",b " << comf.rcArea.bottom << endl;
"canf style " << canf.dwStyle << windisplay_cat.debug() <<
" canf point: x" << canf.ptCurrentPos.x << ",y " << canf.ptCurrentPos.y << "canf style " << canf.dwStyle <<
" canf rect: l " << canf.rcArea.left << ",t " << canf.rcArea.top << ",r " << " 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; canf.rcArea.right << ",b " << canf.rcArea.bottom << endl;
}
comf.dwStyle = CFS_POINT; comf.dwStyle = CFS_POINT;
comf.ptCurrentPos.x = 2000; comf.ptCurrentPos.x = 2000;
comf.ptCurrentPos.y = 2000; comf.ptCurrentPos.y = 2000;
@ -1723,11 +1741,17 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
comf.rcArea.bottom = 0; comf.rcArea.bottom = 0;
#endif #endif
if (ImmSetCompositionWindow(hIMC, &comf)) if (ImmSetCompositionWindow(hIMC, &comf)) {
windisplay_cat.debug() << "set composition form: success\n"; if (windisplay_cat.is_debug()) {
windisplay_cat.debug() << "set composition form: success\n";
}
}
for (int i=0; i<3; ++i) { for (int i=0; i<3; ++i) {
if (ImmSetCandidateWindow(hIMC, &canf)) if (ImmSetCandidateWindow(hIMC, &canf)) {
windisplay_cat.debug() << "set candidate form: success\n"; if (windisplay_cat.is_debug()) {
windisplay_cat.debug() << "set candidate form: success\n";
}
}
canf.dwIndex++; canf.dwIndex++;
} }
} }

View File

@ -233,8 +233,11 @@ load_texture(size_t index) {
if (tex.mHeight == 0) { if (tex.mHeight == 0) {
// Compressed texture. // Compressed texture.
assimp_cat.debug() if (assimp_cat.is_debug()) {
<< "Reading embedded compressed texture with format " << tex.achFormatHint << " and size " << tex.mWidth << "\n"; assimp_cat.debug()
<< "Reading embedded compressed texture with format "
<< tex.achFormatHint << " and size " << tex.mWidth << "\n";
}
stringstream str; stringstream str;
str.write((char*) tex.pcData, tex.mWidth); str.write((char*) tex.pcData, tex.mWidth);
@ -260,8 +263,10 @@ load_texture(size_t index) {
} }
} }
} else { } else {
assimp_cat.debug() if (assimp_cat.is_debug()) {
<< "Reading embedded raw texture with size " << tex.mWidth << "x" << tex.mHeight << "\n"; 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); ptex->setup_2d_texture(tex.mWidth, tex.mHeight, Texture::T_unsigned_byte, Texture::F_rgba);
PTA_uchar data = ptex->modify_ram_image(); 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); t.a4, t.b4, t.c4, t.d4);
PT(CharacterJoint) joint = new CharacterJoint(character, bundle, parent, node.mName.C_Str(), mat); PT(CharacterJoint) joint = new CharacterJoint(character, bundle, parent, node.mName.C_Str(), mat);
assimp_cat.debug() if (assimp_cat.is_debug()) {
<< "Creating joint for: " << node.mName.C_Str() << "\n"; assimp_cat.debug()
<< "Creating joint for: " << node.mName.C_Str() << "\n";
}
for (size_t i = 0; i < node.mNumChildren; ++i) { for (size_t i = 0; i < node.mNumChildren; ++i) {
if (_bonemap.find(node.mChildren[i]->mName.C_Str()) != _bonemap.end()) { 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) { if (node_anim) {
assimp_cat.debug() if (assimp_cat.is_debug()) {
<< "Found channel for node: " << node.mName.C_Str() << "\n"; assimp_cat.debug()
<< "Found channel for node: " << node.mName.C_Str() << "\n";
}
// assimp_cat.debug() << "Num Position Keys " << // assimp_cat.debug() << "Num Position Keys " <<
// node_anim->mNumPositionKeys << "\n"; assimp_cat.debug() << "Num // node_anim->mNumPositionKeys << "\n"; assimp_cat.debug() << "Num
// Rotation Keys " << node_anim->mNumRotationKeys << "\n"; // 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('j', tablej);
group->set_table('k', tablek); group->set_table('k', tablek);
} }
else { else if (assimp_cat.is_debug()) {
assimp_cat.debug() assimp_cat.debug()
<< "No channel found for node: " << node.mName.C_Str() << "\n"; << "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]; const aiBone &bone = *mesh.mBones[i];
CharacterJoint *joint = character->find_joint(bone.mName.C_Str()); CharacterJoint *joint = character->find_joint(bone.mName.C_Str());
if (joint == nullptr) { if (joint == nullptr) {
assimp_cat.debug() if (assimp_cat.is_debug()) {
<< "Could not find joint for bone: " << bone.mName.C_Str() << "\n"; assimp_cat.debug()
<< "Could not find joint for bone: " << bone.mName.C_Str() << "\n";
}
continue; continue;
} }
@ -632,8 +643,11 @@ load_mesh(size_t index) {
aiAnimation &ai_anim = *_scene->mAnimations[i]; aiAnimation &ai_anim = *_scene->mAnimations[i];
bool convert_anim = false; bool convert_anim = false;
assimp_cat.debug() if (assimp_cat.is_debug()) {
<< "Checking to see if anim (" << ai_anim.mName.C_Str() << ") matches character (" << mesh.mName.C_Str() << ")\n"; 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) { for (size_t j = 0; j < ai_anim.mNumChannels; ++j) {
if (assimp_cat.is_spam()) { if (assimp_cat.is_spam()) {
assimp_cat.spam() assimp_cat.spam()
@ -647,8 +661,11 @@ load_mesh(size_t index) {
} }
if (convert_anim) { if (convert_anim) {
assimp_cat.debug() if (assimp_cat.is_debug()) {
<< "Found animation (" << ai_anim.mName.C_Str() << ") for character (" << mesh.mName.C_Str() << ")\n"; assimp_cat.debug()
<< "Found animation (" << ai_anim.mName.C_Str()
<< ") for character (" << mesh.mName.C_Str() << ")\n";
}
// Now create the animation // Now create the animation
unsigned int frames = 0; unsigned int frames = 0;
@ -664,10 +681,12 @@ load_mesh(size_t index) {
} }
} }
PN_stdfloat fps = frames / (ai_anim.mTicksPerSecond * ai_anim.mDuration); PN_stdfloat fps = frames / (ai_anim.mTicksPerSecond * ai_anim.mDuration);
assimp_cat.debug() if (assimp_cat.is_debug()) {
<< "FPS " << fps << "\n"; assimp_cat.debug()
assimp_cat.debug() << "FPS " << fps << "\n";
<< "Frames " << frames << "\n"; assimp_cat.debug()
<< "Frames " << frames << "\n";
}
PT(AnimBundle) bundle = new AnimBundle(mesh.mName.C_Str(), fps, frames); PT(AnimBundle) bundle = new AnimBundle(mesh.mName.C_Str(), fps, frames);
PT(AnimGroup) skeleton = new AnimGroup(bundle, "<skeleton>"); PT(AnimGroup) skeleton = new AnimGroup(bundle, "<skeleton>");
@ -935,8 +954,10 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) {
if (prune) { if (prune) {
// This is an empty node in a hierarchy of joints, prune it. // This is an empty node in a hierarchy of joints, prune it.
parent->remove_child(pnode); parent->remove_child(pnode);
assimp_cat.debug() if (assimp_cat.is_debug()) {
<< "Pruning node '" << name << "'\n"; assimp_cat.debug()
<< "Pruning node '" << name << "'\n";
}
return false; return false;
} else { } else {
return true; return true;
@ -949,7 +970,9 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) {
void AssimpLoader:: void AssimpLoader::
load_light(const aiLight &light) { load_light(const aiLight &light) {
string name (light.mName.data, light.mName.length); 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; aiColor3D col;
aiVector3D vec; aiVector3D vec;

View File

@ -35,7 +35,9 @@ set_default() {
* *
*/ */
void PandaLogger::OnDebug(const char *message) { void PandaLogger::OnDebug(const char *message) {
assimp_cat.debug() << message << "\n"; if (assimp_cat.is_debug()) {
assimp_cat.debug() << message << "\n";
}
} }
/** /**

View File

@ -73,12 +73,16 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) {
} }
// Handle the material stuff // 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); PT_EggMaterial egg_material = new EggMaterial(semantic);
pvector<PT_EggTexture> egg_textures; pvector<PT_EggTexture> egg_textures;
const FCDEffect* effect = instance->GetMaterial()->GetEffect(); const FCDEffect* effect = instance->GetMaterial()->GetEffect();
if (effect == nullptr) { 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 { } else {
// Grab the common profile effect // Grab the common profile effect
const FCDEffectStandard* effect_common = (FCDEffectStandard *)effect->FindProfile(FUDaeProfileType::COMMON); 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 daeegg_cat.info() << "Ignoring effect referenced by material with semantic " << semantic
<< " because it has no common profile" << endl; << " because it has no common profile" << endl;
} else { } 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 // Set the material parameters
egg_material->set_amb(TO_COLOR(effect_common->GetAmbientColor())); egg_material->set_amb(TO_COLOR(effect_common->GetAmbientColor()));
// We already process transparency using blend modes LVecBase4 diffuse = // We already process transparency using blend modes LVecBase4 diffuse =
@ -115,7 +121,9 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) {
// Find an <extra> tag to support some extra stuff from extensions // Find an <extra> tag to support some extra stuff from extensions
process_extra(semantic, effect->GetExtra()); 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; _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 = Filename::from_os_specific(FROM_FSTRING(image->GetFilename()));
texpath.make_canonical(); texpath.make_canonical();
texpath.make_relative_to(docpath.get_dirname(), true); 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 { } else {
// Never mind. // Never mind.
texpath = Filename::from_os_specific(FROM_FSTRING(image->GetFilename())); 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 // Find a set of UV coordinates
const FCDEffectParameterInt* uvset = effect_common->GetTexture(bucket, tx)->GetSet(); const FCDEffectParameterInt* uvset = effect_common->GetTexture(bucket, tx)->GetSet();
if (uvset != nullptr) { 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())); string uvset_semantic (FROM_FSTRING(uvset->GetSemantic()));
// Only set the UV name if this UV set actually exists. // 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) { if (_materials.count(semantic) > 0) {
to->set_material(_materials[semantic]->_egg_material); to->set_material(_materials[semantic]->_egg_material);
for (pvector<PT_EggTexture>::iterator it = _materials[semantic]->_egg_textures.begin(); it != _materials[semantic]->_egg_textures.end(); ++it) { for (pvector<PT_EggTexture>::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->add_texture(*it);
} }
to->set_bface_flag(_materials[semantic]->_double_sided); to->set_bface_flag(_materials[semantic]->_double_sided);
@ -271,11 +285,15 @@ get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semanti
// semantic TEXCOORD. // semantic TEXCOORD.
for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) { for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) {
if (_materials[semantic]->_uvsets[i]->_input_set == input_set) { 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; 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 ""; return "";

View File

@ -175,7 +175,9 @@ convert_file(const Filename &filename) {
if (mesh != nullptr) { if (mesh != nullptr) {
PT(DaeMaterials) materials = new DaeMaterials(character->_instance); 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); process_mesh(character->_node_group, mesh, materials, character);
} }
} }
@ -373,7 +375,9 @@ void DAEToEggConverter::
process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) { process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) {
nassertv(node != nullptr); nassertv(node != nullptr);
string node_id = FROM_FSTRING(node->GetDaeId()); 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 // Create an egg group for this node
PT(EggGroup) node_group = new EggGroup(FROM_FSTRING(node->GetDaeId())); 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) { DaeMaterials *materials, DaeCharacter *character) {
nassertv(mesh != nullptr); 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 // Create the egg stuff to hold this mesh
PT(EggGroup) mesh_group = new EggGroup(FROM_FSTRING(mesh->GetDaeId())); 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 // First retrieve the vertex source
if (mesh->GetSourceCount() == 0) { 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; return;
} }
const FCDGeometrySource* vsource = mesh->FindSourceByType(FUDaeGeometryInput::POSITION); const FCDGeometrySource* vsource = mesh->FindSourceByType(FUDaeGeometryInput::POSITION);
if (vsource == nullptr) { 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; return;
} }
// Loop through the polygon groups and add them // 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; if (mesh->GetPolygonsCount() == 0) return;
// This is an array of pointers, I know. But since they are refcounted, I // 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(); const FCDGeometryMesh *mesh = controller->GetBaseGeometry()->GetMesh();
if (mesh != nullptr) { if (mesh != nullptr) {
PT(DaeMaterials) materials = new DaeMaterials(instance); 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); process_mesh(parent, mesh, materials);
} }
} else { } else {

View File

@ -87,8 +87,10 @@ find_shader_for_node(MObject node, bool legacy_shader) {
} }
// Well, we didn't find a ShadingEngine after all. Huh. // Well, we didn't find a ShadingEngine after all. Huh.
maya_cat.debug() if (maya_cat.is_debug()) {
<< node_fn.name().asChar() << " : no shading engine found.\n"; maya_cat.debug()
<< node_fn.name().asChar() << " : no shading engine found.\n";
}
return nullptr; return nullptr;
} }